Online Coding Lessons JavaScript Coding for Kids 2 — Questions and Answers
Question 1: Which keyword creates a variable that can be changed later in JavaScript?
- let (Correct answer)
- const
- fixed
- lock
Correct answer: let
The let keyword makes a variable whose value can be reassigned.
Question 2: What will alert(2 + 3) show on the screen?
- 5 (Correct answer)
- 23
- 2 + 3
- Error
Correct answer: 5
JavaScript adds the numbers 2 and 3 to get 5.
Question 3: How do you write a single-line comment in JavaScript?
- // this is a comment (Correct answer)
- <!-- comment -->
- # comment
- ** comment
Correct answer: // this is a comment
Two slashes start a single-line comment that JavaScript ignores.
Question 4: Which symbol joins two pieces of text (strings) together?
- + (Correct answer)
- &
- *
- %
Correct answer: +
The plus sign combines strings in a process called concatenation.
Question 5: What does the prompt() function do in a web page?
- Asks the user to type something (Correct answer)
- Plays a sound
- Changes the color
- Closes the page
Correct answer: Asks the user to type something
The prompt() function shows a box where the user can type an answer.
Question 6: Which value is a boolean in JavaScript?
- true (Correct answer)
- "hello"
- 42
- [1, 2]
Correct answer: true
A boolean is either true or false.
Question 7: What punctuation usually ends a line of JavaScript code?
- Semicolon ; (Correct answer)
- Period .
- Comma ,
- Colon :
Correct answer: Semicolon ;
A semicolon marks the end of a JavaScript statement.
Which keyword creates a variable that can be changed later in JavaScript?