Coding Unit 6

0.0(0)
studied byStudied by 0 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/15

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

16 Terms

1
New cards

What are valid values for a Boolean

True & False

2
New cards

What is the statement that allows us to run code only if something is true

if statement

3
New cards

What kind of statement allows us to run code if one condition is true but another statement otherwise

if/else statement

4
New cards

function main() {

let isClean = false;

if (isClean) {

console.log ("Thanks for taking care of your space!");

} else { console.log("Time to tidy up!"); }

}

main();

What will be the output of this code?

Time to tidy up!

5
New cards

What symbol represents "and" in coding

&&

6
New cards

What symbol represents "or" in coding

| |

7
New cards

let isSaturday = true;

let isSunday = false;

let isWeekend = isSaturday || isSunday;

After this, what is the value isWeekend?

true

8
New cards

What is the proper way to compare if two values are equal?

==

9
New cards

What is the proper way to say not equal in coding

!=

10
New cards

let flower = "violet";

if (flower == "rose") { console.log ("Roses are red, violets are blue.");

} else { console.log ("A rose by any other name would smell as sweet.");

}

What would be the output of this code?

A rose by any other name would smell as sweet.

11
New cards

let num = 55;

if (num == 3) { circle.setColor("orange");

} else if (num % 5 == 0) {

circle.setColor("yellow");

} else if (num > 50) { circle.setColor("green");

} else { circle.setColor("red"); }

What will be the output for this code

Yellow Circle

12
New cards

let num = 10;

while (num > 0) {

console.log("hello");

num = num - 1;

}

How many times will this print "hello"

10 times

13
New cards

let num = 50;

while (num < 100) { console.log("hello");

}

How many times will this program print "hello"

This will make an infinite loop.

14
New cards

What does the break statement do?

Instantly stops a loop.

15
New cards

for (let i = 0; i < 5; i++) { console.log("hello");

}

How many times will this code print "hello"?

5

16
New cards

for (let i = 0; i < 3; i++) {

let sum = 0;

sum = sum + i;

}

What is the final value of sum in this code?

2