0%
Checking the code runner…

Instructions

Lesson 2 of 4

Variables and Types

JavaScript has two everyday ways to make a variable:

  • const for values that won't be reassigned
  • let for values that will change

Template literals

Backtick strings (`) can include values with ${...}:

Types

typeof tells you what kind of value you have:

Functions

A function packages up code you can reuse. return sends a value back:

Exercise: Introduce a hobbit

Write a function introduce(name, age) that returns <name> is <age> years old.

For example, introduce("Sam", 38) returns "Sam is 38 years old.".

Your turn!

Write your code in and press Submit answer.

  • console.log(introduce("Sam", 38)); → Sam is 38 years old.
  • console.log(introduce("Bilbo", 111)); → Bilbo is 111 years old.
  • plus 1 hidden check

Help

Hint

Use a template literal: return `${name} is ${age} years old.`;

Pass the exercise to complete this lesson.

Terminal
Press Run to see your output here.