Variables
Data Types
Conditionals
Built-In Objects
General Intro
100

____Holds reusable data in a program and associated it with a name

What are  Variables?

100

Variables that have not been initialized store the primitive data type _____.

undefined

Beware:

There are a few general rules for naming variables:

  • Variable names cannot start with numbers.
  • Variable names are case sensitive, so myName and myname would be different variables. It is bad practice to create two variables that have the same name using different cases.
  • Variable names cannot be the same as keywords. 
100

The following will print . . . 

let tool = 'marker';

// Use short circuit evaluation to assign  writingUtensil variable below:

let writingUtensil = tool || 'pen';

console.log(`The ${writingUtensil} is mightier than the sword.`);

The marker is mightier than the sword.

100

This will print:

console.log(Math.floor(43.8));

43

100

The ____ object is used to represent and manipulate a sequence of characters.

The String object is used to represent and manipulate a sequence of characters. 

200

Using template literals to embed variables into strings is called ____.

What is string interpolation?

200

This data type represents the intentional absence of a value, and is represented by the keyword ____(without quotes).

Null

200

The following code will print 

let username = '';
let defaultName = username || 'Stranger';
 
console.log(defaultName);

// Prints: Stranger

200

console.log(Math.ceil(43.8));

44

200

This will print:

console.log('    Remove whitespace   '.trim());

Remove whitespace


.trim() - Use a string method to log the following string without whitespace at the beginning and end of it.

300

What is the outcome of the following code snippet?

console.log('Hello World'.length);

11

300

This data type is denoted by the keyword ____(without quotes).  It also represents the absence of a value though it has a different use than null.

Undefined

300

This will print:

let username = '';
let defaultName;
 
if (username) {
  defaultName = username;
} else {
  defaultName = 'Stranger';
}
 
console.log(defaultName);

// Prints: Stranger

So which values are falsy— or evaluate to false when checked as a condition? The list of falsy values includes:

0

Empty strings like "" or ''

null which represent when there is no value at all

undefined which represent when a declared variable lacks a value

NaN, or Not a Number

300

console.log(Number.isInteger(2022));

true

300

This prints: 

// Modulo 

console.log(10 % 5);

0

400

True or False - The correct way to call the random method on the Math global object is _____?

math.random;

False 

Math.random()

400

A newer feature to the JS language, symbols are unique identifiers, useful in more complex coding.

Symbol

400

let athleteFinalPosition = 'first place';

switch (athleteFinalPosition){

   case   'first place':

   console.log('You get the gold medal!');

    break;

    case   'second place':

    console.log('You get the silver medal!');

    break;

    case   'third place':

    console.log('You get the bronze medal!');

    break;

    default:

    console.log('No medal awarded.');

     break;

}//what is printed when running the switch statement?

You get the gold medal!

400

This will print:

'hello'.toUpperCase()

HELLO

400

 a ____ variable cannot be reassigned because it is _____. If you try to reassign this variable, you’ll get a TypeError.

const  constant

500

What would the following code snippet print?

const food = 'chicken';

food = 'sushi';

An error

500

A Collections of related data is called

Object

500

which of the following variables contains a trutht value?

a. let varOne = 'false';   b. let varTwo = false;

c. let varThree = 0; d. let varFour = ' ';

a. let varOne = 'false';

non-empty strings are truthy!

500

This will print:

console.log('Hey'.startsWith('H'));

Prints: true

500

//This will print

const entree = "Enchiladas";

console.log(entree);

entree = 'Tacos';

Enchiladas
/home/ccuser/workspace/learn-javascript-variables-constV2/main.js:3 entree = 'Tacos';       ^
TypeError: Assignment to constant variable.    at Object.<anonymous> (/home/ccuser/workspace/learn-javascript-variables-constV2/main.js:3:8)    at Module._compile (module.js:571:32)    at Object.Module._extensions..js (module.js:580:10)    at Module.load (module.js:488:32)    at tryModuleLoad (module.js:447:12)    at Function.Module._load (module.js:439:3)    at Module.runMain (module.js:605:10)    at run (bootstrap_node.js:427:7)    at startup (bootstrap_node.js:151:9)    at bootstrap_node.js:542:3

M
e
n
u