JAVASCRIPT Flashcards

(51 cards)

1
Q

Where does JavaScript run?

A

In the browser, no need for a development environment.

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

What is built-in the browser to run JavaScript code?

A

The JavaScript console.

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

How do you open the JavaScript console?

A

ctrl+shft+J

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

How do you clear the console?

A

by pressing the circular icon with the bar running through it.

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

What is a line of JavaScript code called?

A

A JavaScript statement.

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

How to bring up a pop-up box with a statement on it?

A

alert();

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

How to bring up the previous command on the console?

A

use the up arrow.

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

Code for a dialog-box with the words “hi” …

A

alert(“hi”);

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

Code to send a message to the console with the word “Hello” …

A

console.log(“Hello”);

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

Code to send the text “Hi” to the webpage you’re on …

A

document.write(“Hi”);

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

How do you to the next line in the console without entering your current line of code?

A

shft + return

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

Code to write an < H1 > with the text “Fuck You” to the current webpage you’re on …

A

document.write( “ < h1 > Fuck You < / h1 > “ );

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

How does code run?

A

line by line

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

Where do you place JavaScript code?

A

In a seperate file, but in the same folder of your html, much like a CSS file.

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

What executes JavaScript code?

A

The JavaScript engine built into the browser.

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

What extension do JavaScript files have?

A

.js

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

Where are JavaScript links usually placed in HTML files?

A

Just before the ending < body > tag.

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

Code for a link from an html file to a JavaScript file named script.js which is in a file named js …

A

< script src = “ js / script.js “ > < / script >

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

Can you link more than one JavaScript file in your html file?

A

YES, YES a thousand times YES, ALREADY!!!

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

Where are JavaScript errors logged?

A

In the JavaScript console.

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

What info will be listed on the error line in the console?

A

the file and line of error

22
Q

Is JavaScript case sensitive?

23
Q

How do you write a JavaScript comment?

A

// till eol, end of line

/* mutline

like

this */

24
Q

What are the three ways you can declare a JavaScript variable?

A

var

let

const

25
Declare a variable named score ...
var score; const score; let score;
26
Declare and assign a value, 0, to the variable named score ...
var score = 0; let score = 0; const score = 0;
27
What is meant by "reassigning a variable"?
It is when you overwrite a value in a variable with a new value. var score = 0; score = 1; notice you don't have to write var twice, which is nice.
28
Which type of variable can you not use to reassign a value to?
const
29
What are some of the rules for naming variables?
1. Variable names cannot start with a number. (9lives, no good). 2. Names can only contain letters, numbers, and the $ and _ characters. 3. Use camelCase for multiWord variable names. 4. Make variable names meaningful. 5. Don't use KW's.
30
Code an example of the addition assignment operator ...
var score = 5; score += 10; console.log(score); what would score be now? 15
31
Code showing how you can use variable names to add up values just as you would use numbers ...
var score = 15; var bonusPoints = 100; var finalScore = score + bonusPoints; document.write(finalScore); 115
32
What can one say about spacing around the = in JavaScript?
\_ = \_
33
How do you list strings?
Use double quotation marks "some string".
34
How would you use html in a string?
If you're using html in a string and have to use double quotes, use single quotes outside your string ... const htmlSnippet = ' \< h1 class = " headline " \> '
35
What is an escape character and how would you use it?
\ is the escape character and you use it before a character you want to use literally and not code-wise, i.e. ... const message = ' I\'m a programmer ! ' ;
36
How to use an escape character when dealing with multi-line strings?
const multiLine = " Hello , students \ Welcome to JS
37
Code to find the length of a string ...
const passPhrase = "Open Sesame"; console.log(passPhrase.length); 11
38
In JavaScript what is an action you can take called?
this one is called a method
39
Code for making a string all lower case ...
const passPhrase = "I have spoken"; console.log(" passPhrase.toLowerCase()); \>i have spoken
40
Code to list a string to all upper case ...
const passPhrase = "i have spoken"; console.log(passPhrase.toUpperCase()); \>I HAVE SPOKEN
41
How to code for a question dialog box and to get a response to use somehow ...
use the prompt() ... prompt("What is your major malfunction?");
42
How would you use the prompt to save some value ...
const name = prompt("What is your name?'); console.log(name); or alert(name); or document.write( " \< h1 \> name \< / h1 \> " );
43
What is the process called when combining two or more strings together?
this one is called string concatenation
44
How to code to concatenate two string together?
"My favorite" + "Movies"; My favorite Movies
45
How to code using a prompt and a string ...
const name = prompt("What is your name?"); const message = " Hello " + name; console.log(message); or alert(message); or document.write(message);
46
Code for using a template literal ...
const name = prompt("What is your name?"); const message = `Hello, ${name}`; console.log(message);
47
What are some true "things" about template literals?
1. With template literals you don't have to worry about spaces or escape characters. 2. With template literals you can write multi-line strings w/out any special characters, no back-slash for example.
48
How to display a value of a string onto a page ...
It's a two step process: 1. Select the html element where you want your content to appear: document. querySelector('main'); 2. What content you want to insert into that element.
49
Code using a querySelector ...
const message = "What the fuck ... over"; document.querySelector('main').innerHTML = message;
50
Code using some template literals using Great Gatsby ...
const title = " The Great Gatsby "; const price = " 14.99 "; const book = `${title} : $${price}`;
51