Code Reading Flashcards

1
Q

const fullName: string = ‘Cody Miller’

A

The string ‘Cody Miller’ is being assigned to the variable fullName of type string

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

const isCool: boolean = true;

A

The boolean value true is being assigned to the variable isCool of type boolean

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

const totalPets: number = 1000;

A

The number 1000 is being assigned to the variable totalPets of type number

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

console.log(‘value of fullName:’, fullName);

A

The log method of the console object is being called with two arguments: The string value of fullName and the value of the variable fullName of type string.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

const area: number = width * height;

A

The result of the expression width times height, both of type number, is being assigned to the variable area of type number.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

motto += ‘ is the GOAT’;

A

The string value of the variable motto is being concatenated with ‘ is the GOAT’, and the result is being reassigned to the variable motto of type string.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

const bio: string = My name is ${firstName} ${lastName} and I am ${age} years old.;

A

A template literal with the variables firstName, lastName, and age is being interpolated and assigned to the variable bio of type string.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

const student: { firstName: string, lastName: string } = {
firstName: ‘Luke’,
lastName: ‘Skywalker’
};

A

// A TypeScript object is being assigned to the variable student with a firstName property of type string and a lastName property of type string.
// the string Luke is being assigned to the property firstName

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

const fullName: string = student.firstName + ‘ ‘ + student.lastName;

A

The firstName property of the student object is being concatenated with a space, and then with the lastName property of the student object. The result is assigned to the variable fullName of type string.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

const colors: string[] = [‘red’, ‘white’, ‘blue’];

A

An array of strings [‘red’, ‘white’, ‘blue’] is being assigned to the variable colors of type array of strings.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

console.log(‘value of colors[0]:’, colors[0])

A

The log method of the console object is being called with two arguments:a string, and colors at 0.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

colors[2] = ‘green’;

A

The string ‘green’ is being assigned to colors at 2

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

function convertMinutesToSeconds(minutes: number): number {
const seconds: number = minutes * 60;
return seconds;
}

A

A function named convertMinutesToSeconds is being defined with one parameter minutes of type number. It returns a value of type number.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

const convertMinutesToSecondsResult: number = convertMinutesToSeconds(5);

A

The function convertMinutesToSeconds is being called with the argument 5, and the returned value of that call is being assigned to the variable convertMinutesToSecondsResult of type number.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

function getArea(width: number, height: number): number {
const area: number = width * height;
return area;
}

A

A function named getArea is being defined with two parameters: width and height, both of type number. It returns a value of type number.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

const getAreaResult: number = getArea(17, 42);

A

The function getArea is being called with two arguments: 17 and 42, both of type number. The returned value is being assigned to the variable getAreaResult of type number.

17
Q

function isUnderFive(number: number): boolean {
if (number < 5) {
return true;
} else {
return false;
}
}

A

A function named isUnderFive is being defined with one parameter number of type number. It returns a value of type boolean.

18
Q

function recommendMovie(genre: string): string {
switch (genre) {
case ‘action’:
return ‘Die Hard’;
// other cases…
}
}

A

A function named recommendMovie is being defined with one parameter genre of type string. It returns a value of type string.

19
Q

const doggo: { bork: () => string; lick: () => string } = {
bork: function () {
return ‘bork! bork! bork!’;
},
lick: function () {
return ‘mlem’;
},
};

A

// An object with two methods, ‘bork’ and ‘lick’, both of type ‘function that returns a string’, is being assigned to the variable ‘doggo’.
// The ‘doggo’ object has a ‘bork’ property, which is a function returning a string, and a ‘lick’ property, which is also a function returning a string.
// The ‘bork’ method is being defined as a function that takes no parameters and returns the string ‘bork! bork! bork!’.
// The ‘lick’ method is being defined as a function that takes no parameters and returns the string ‘mlem’.

20
Q

Switch Statement / Case Clause

A

TBW

21
Q

Conditional Statement

A

TBW

22
Q

HTML elements

A

TBW

23
Q

CSS

A

TBW