Display Your Name in JavaScript

let name = "...". console.log can take extra arguments. They get spaces between them.

BeginnerBasic ProgramsExample 2 of 10
display-your-name.js
1// Using a variable to store and display name
2let name = "John Doe";
3console.log("My name is:", name);

Output

My name is: John Doe

What's going on

let is the one you want. const if it will not change. var is the leftover.

console.log("My name is:", name) prints two things with a space.