11. How many times will the following code print the word 'Hello'?
var i = 0;
while(i < 3) {
console.log("Hello");
i++;
}
- 1
- 2
- 3
- 4
12. How many times will the following code print the word 'Hello'?
for (i = 0; i < 2; i++) {
for (var j = 0; j < 3; j++) {
console.log("Hello");
}
}
- 2
- 3
- 4
- 6
13. Based on the following code, what will print out when the variable i has the value 7 ?
if(i <= 5) {
console.log("Hello");
} else if(i <= 10) {
console.log("Goodnight");
} else {
console.log("Goodbye");
}
- Hello
- Goodnight
- Goodbye
14. Based on the following code, what will print out when the variable i has the value 3 ?
switch(i) {
case 1: console.log("Hello");
break;
case 2:
console.log("Goodnight");
break;
case 3:
console.log("Goodbye");
break;
}
- Hello
- Goodnight
- Goodbye
15. Based on the following code, what will print out when the variable i has the value 3 ?
if(i == 2 || i == 3) {
console.log("Hello");
} else {
console.log("Goodbye");
}
- Hello
- Goodbye
Module quiz: Introduction to JavaScript
17. Which of the following are valid comments in JavaScript? Select all that apply.
- Â \ Comment 1
- // Comment 2
- Â ##
## Comment 3
## - /*
* Comment 4
*/
18. Which of the following are valid data types in JavaScript? Select all that apply.
- string
- numbers
- booleans
- null