variables functions and conditionals

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/38

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 4:30 PM on 3/24/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No analytics yet

Send a link to your students to track their progress

39 Terms

1
New cards

What is a variable in programming?

A variable is a named storage location in memory that can hold a value.

2
New cards

Which of the following is an example of a boolean value?

true or false.

3
New cards

What does the following code do? let x = 5; x = x + 3;

This code assigns the value of 8 to variable x.

4
New cards

If let a = 10 and let b = 5, what is the value of a == b?

The value is false.

5
New cards

What happens when you assign a new value to a variable?

The previous value is replaced by the new value.

6
New cards

True or False: The expression x = 10 checks if x is equal to 10.

False; x = 10 assigns the value 10 to x.

7
New cards

What are parameters in a function?

Parameters are variables listed inside the parentheses of a function that hold input values.

8
New cards

In JavaScript-style pseudocode, how would you define a function called addNumbers that takes two parameters?

function addNumbers(num1, num2) { /* function code */ }

9
New cards

What does a function return if it does not have a return statement?

It returns undefined.

10
New cards

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.

11
New cards

True or False: You can pass arguments to a function when calling it.

True.

12
New cards

What is the purpose of using functions in programming?

Functions help organize code and allow for reuse of code segments.

13
New cards

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'.

14
New cards

What is the correct syntax for an if statement in JavaScript-style pseudocode?

if (condition) { /* code to execute */ }

15
New cards

What does an else-if statement do?

It allows you to check additional conditions if the previous conditions were false.

16
New cards

In the expression if (a && b), what does the && operator do?

It checks if both a and b are true.

17
New cards

Compare = and ==. What is the difference?

= is an assignment operator, while == checks for equality.

18
New cards

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'.

19
New cards

What are logical operators?

Logical operators combine boolean expressions (e.g., AND, OR, NOT).

20
New cards

Complete the following conditional:
if (score >= 90) { // code to execute } else \_\_\_\_\_\_\_\_\_\_\_\_ { // code to execute }

else if (score < 90 && score >= 80) or else.

21
New cards

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.

22
New cards

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'.

23
New cards

True or False: Conditionals can only use integer comparisons (e.g., >, <=).

False; conditionals can compare any datatype, including strings and booleans.

24
New cards

In the code snippet let days = ['Mon', 'Tue', 'Wed']; console.log(days[1]);, what will be printed?

It will print 'Tue'.

25
New cards

What does the following code return?
``function multiply(a, b) { return a * b; } console.log(multiply(2, 3));

It will return 6.

26
New cards

How would you check if two variables a and b are equal?

Using the equality operator a == b.

27
New cards

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.

28
New cards

For the following function, what will be the output when called with processData('Hello')?
function processData(text) { return text.length; }

It will return 5.

29
New cards

What does the comparison operator != do?

It checks if two values are not equal.

30
New cards

If you have let userAge = 16; and if (userAge >= 18), will the condition be true or false?

The condition will be false.

31
New cards

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.

32
New cards

In the expression x >= 10 && x < 20, what will it evaluate to if x is 15?

It will evaluate to true.

33
New cards

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.

34
New cards

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.

35
New cards

What keyword is used to define a function in JavaScript-style pseudocode?

The keyword is function.

36
New cards

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.

37
New cards

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'.

38
New cards

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'.

39
New cards

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.

Explore top notes

note
greece
Updated 1039d ago
0.0(0)
note
MAGMA SERIES
Updated 430d ago
0.0(0)
note
The congregations in Latin
Updated 1011d ago
0.0(0)
note
2.4: ions and ionic compounds
Updated 1257d ago
0.0(0)
note
CGO casus 6
Updated 428d ago
0.0(0)
note
greece
Updated 1039d ago
0.0(0)
note
MAGMA SERIES
Updated 430d ago
0.0(0)
note
The congregations in Latin
Updated 1011d ago
0.0(0)
note
2.4: ions and ionic compounds
Updated 1257d ago
0.0(0)
note
CGO casus 6
Updated 428d ago
0.0(0)

Explore top flashcards

flashcards
McWilliams ACT Vocabulary 1-50
50
Updated 1211d ago
0.0(0)
flashcards
Chapter 8 - Comp Gov.
21
Updated 862d ago
0.0(0)
flashcards
Honors Chemistry elements
57
Updated 197d ago
0.0(0)
flashcards
13 Colonies Test Prep 2025
41
Updated 99d ago
0.0(0)
flashcards
AP Chemistry Unit 2 Review
37
Updated 386d ago
0.0(0)
flashcards
MSKLEC_ TMJ
98
Updated 520d ago
0.0(0)
flashcards
McWilliams ACT Vocabulary 1-50
50
Updated 1211d ago
0.0(0)
flashcards
Chapter 8 - Comp Gov.
21
Updated 862d ago
0.0(0)
flashcards
Honors Chemistry elements
57
Updated 197d ago
0.0(0)
flashcards
13 Colonies Test Prep 2025
41
Updated 99d ago
0.0(0)
flashcards
AP Chemistry Unit 2 Review
37
Updated 386d ago
0.0(0)
flashcards
MSKLEC_ TMJ
98
Updated 520d ago
0.0(0)