1/38
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai |
|---|
No analytics yet
Send a link to your students to track their progress
What is a variable in programming?
A variable is a named storage location in memory that can hold a value.
Which of the following is an example of a boolean value?
true or false.
What does the following code do? let x = 5; x = x + 3;
This code assigns the value of 8 to variable x.
If let a = 10 and let b = 5, what is the value of a == b?
The value is false.
What happens when you assign a new value to a variable?
The previous value is replaced by the new value.
True or False: The expression x = 10 checks if x is equal to 10.
False; x = 10 assigns the value 10 to x.
What are parameters in a function?
Parameters are variables listed inside the parentheses of a function that hold input values.
In JavaScript-style pseudocode, how would you define a function called addNumbers that takes two parameters?
function addNumbers(num1, num2) { /* function code */ }
What does a function return if it does not have a return statement?
It returns undefined.
Given the following function, what will be the output when calculate(3) is called? function calculate(num) {
return num * 2;
}
The output will be 6.
True or False: You can pass arguments to a function when calling it.
True.
What is the purpose of using functions in programming?
Functions help organize code and allow for reuse of code segments.
Predict the output of the following code snippet:let result = 10;
if (result > 5) {
console.log('Greater');
} else {
console.log('Lesser');
}
The output will be 'Greater'.
What is the correct syntax for an if statement in JavaScript-style pseudocode?
if (condition) { /* code to execute */ }
What does an else-if statement do?
It allows you to check additional conditions if the previous conditions were false.
In the expression if (a && b), what does the && operator do?
It checks if both a and b are true.
Compare = and ==. What is the difference?
= is an assignment operator, while == checks for equality.
Given the following snippet, what will be the output? let x = 4;
if (x < 5) {
console.log('x is less than 5');
} else {
console.log('x is 5 or more');
}
The output will be 'x is less than 5'.
What are logical operators?
Logical operators combine boolean expressions (e.g., AND, OR, NOT).
Complete the following conditional: if (score >= 90) {
// code to execute
} else \_\_\_\_\_\_\_\_\_\_\_\_ {
// code to execute
}
else if (score < 90 && score >= 80) or else.
What is the output of the following code? ``let a = true;
let b = false;
let c = a || b;
console.log(c);
The output will be true.
If the following function is called: function checkNumber(num) {
if (num > 0) {
return 'Positive';
}
return 'Not Positive';
}
What will checkNumber(-3) return?
It will return 'Not Positive'.
True or False: Conditionals can only use integer comparisons (e.g., >, <=).
False; conditionals can compare any datatype, including strings and booleans.
In the code snippet let days = ['Mon', 'Tue', 'Wed']; console.log(days[1]);, what will be printed?
It will print 'Tue'.
What does the following code return? ``function multiply(a, b) {
return a * b;
}
console.log(multiply(2, 3));
It will return 6.
How would you check if two variables a and b are equal?
Using the equality operator a == b.
Given the following code, what is the value of count after execution? let count = 0;
if (true) {
count += 1;
} else {
count += 2;
}
The value of count will be 1.
For the following function, what will be the output when called with processData('Hello')? function processData(text) {
return text.length;
}
It will return 5.
What does the comparison operator != do?
It checks if two values are not equal.
If you have let userAge = 16; and if (userAge >= 18), will the condition be true or false?
The condition will be false.
When calling a function with two arguments, how many parameters must the function be defined with?
The function must be defined with at least two parameters.
In the expression x >= 10 && x < 20, what will it evaluate to if x is 15?
It will evaluate to true.
If the code contains let value = 12;
if (value < 10) {
value = value - 2;
}, what will the final value of value be?
The final value will be 12.
True or False: A function can return more than one value at a time.
False; a function can only return one value, but that value can be an array or object containing multiple values.
What keyword is used to define a function in JavaScript-style pseudocode?
The keyword is function.
If a boolean expression evaluates to false in an if statement, which part of the if-else structure will run?
The else part will run.
Given the following code:let isRaining = false;
if (isRaining) {
console.log('Take an umbrella');
} else {
console.log('Enjoy the weather');
}
What will be printed?
It will print 'Enjoy the weather'.
What would the output be after executing this code? let x = 20;
if (x < 25) {
console.log('Less than 25');
} else if (x < 30) {
console.log('Between 25 and 30');
} else {
console.log('30 or more');
}
It will print 'Less than 25'.
What does the following code snippet do? let message = 'Good Morning';
console.log(message.length);
It prints the length of the message, which is 12.