programming with javascript coursera week 1 quiz answers
Knowledge check: Welcome to Programming
3. What is the % operator?
- The modulus operator
- The division operator
- The concatenation operator
4. What happens when you use the + operator on two strings?
- They get joined into a single string
- You can’t use the + operator on two strings
5. What is the operator symbol && represent in JavaScript?
- The logical OR operator
- The logical AND operator
- The logical NOT operator
6. What happens when you use the + operator on a string and a number?
- Nothing – you can’t use the + operator on different data types
- They get joined together as if both of them were strings
Knowledge check - Conditionals and loops
8. Based on the following code, what will print out when the variable i has the value 3 ?
if(i < 5) {
console.log("Hello");
} else {
console.log("Goodbye");
}
- Hello
- Goodbye
Shuffle Q/A 1
9. Based on the following code, what will print out when the variable i has the value 1 ?
if(i == 0 && i == 1) {
console.log("Hello");
} else {
console.log("Goodbye");
}
- Hello
- Goodbye
10. How many times will the following code print the word 'Hello'?
for (i = 0; i < 2; i++) {
console.log("Hello");
}
- 1
- 2
- 3
- 4