Lesson 2 of 4
Variables and Types
JavaScript has two everyday ways to make a variable:
constfor values that won't be reassignedletfor 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