CS Basics Practice Quiz¶
Topics To Know¶
data types
conditionals (if/else if/else)
loops (while and/or for)
functions
boolean logic/logical operators
solving CodingJS problems to practice these ideas
Question 1¶
- float
- Try again!
- int
- Try again!
- string
- Try again! Strings are enclosed in "quotation marks".
- number
- Try again!
- boolean
- Great! Booleans are either true or false.
Q-1: In JavaScript, what is the data type of: true
Question 2¶
- float
- Try again!
- int
- Try again!
- string
- Great! Strings are enclosed in "quotation marks".
- number
- Try again!
- boolean
- Try again! Booleans are not enclosed in "quotation marks".
Q-2: In JavaScript, what is the data type of: “this is false”
Question 3¶
- float
- Try again! There aren't different data types for int and float in JS.
- int
- Try again! There aren't different data types for int and float in JS.
- string
- Try again! Strings are enclosed in "quotation marks".
- number
- Great! There aren't different data types for int and float in JS.
- boolean
- Try again! Booleans are either true or false.
Q-3: In JavaScript, what is the data type of: 56
Question 4¶
Q-4: What will the following program print?:
let someNumber = 10;
while (someNumber <= 20) {
if (someNumber < 18) {
someNumber = someNumber + 3;
}
else {
someNumber += 2;
}
}
console.log(someNumber);
Question 5¶
Q-5: What will the following program print?:
let person = "Arthur Dent";
let answer = 42;
if (answer > 50) {
person = "Ford Prefect";
}
if (answer > 30) {
person = "Zaphod Beeblebrox";
}
if (answer > 10) {
person = "Marvin";
}
console.log(person);
Question 6¶
Q-6: What will the following program print?:
let person = "Arthur Dent";
let answer = 42;
if (answer > 50) {
person = "Ford Prefect";
}
else if (answer > 30) {
person = "Zaphod Beeblebrox";
}
else if (answer > 10) {
person = "Marvin";
}
console.log(person);
Question 7¶
Q-7: What will the following program print?:
function somethingUnknown(firstThing, secondThing) {
if (secondThing === "Vogons") {
return "Panic";
}
if (firstThing === "Trillian") {
return "Don't Panic";
}
return 42;
}
console.log(somethingUnknown("Trillian", "Vogons"))
Question 8¶
Q-8: What will the following program print?:
function somethingUnknown(firstThing, secondThing) {
if (secondThing === "Vogons") {
return "Panic";
}
if (firstThing === "Trillian") {
return "Don't Panic";
}
return 42;
}
console.log(somethingUnknown("Trillian", "Ford"))
Question 9¶
Q-9: What will the following program print?:
function somethingUnknown(firstThing, secondThing) {
if (secondThing === "Vogons") {
return "Panic";
}
if (firstThing === "Trillian") {
return "Don't Panic";
}
return 42;
}
console.log(somethingUnknown("Marvin", "Ford"))
Question 10¶
- true
- Great!
- false
- Try again!
- An error will occur.
- Try again!
- None of the above.
- Try again!
Q-10: Given the following function and function call, what would be printed?:
function mysteriousThing(x, y) {
return (x === 6 || y !== 14 || x*y === 42);
}
console.log( mysteriousThing(3, 14) )
Question 11¶
- true
- Try again!
- false
- Great!
- An error will occur.
- Try again!
- None of the above.
- Try again!
Q-11: Given the following function and function call, what would be printed?:
function mysteriousThing(x, y) {
return (x === 6 || y !== 14 && x*y === 42);
}
console.log( mysteriousThing(3, 14) )
Question 12¶
First, turn on the Practice Quiz Mode of CodingJS. This will hide the test cases that are used when checking your code. Now solve the loneTeen CodingJS practice problem.
Question 13¶
Make sure the Practice Quiz Mode of CodingJS is turned on. Now solve the in1to10 CodingJS practice problem.