Week 1 Flashcards

1
Q

What does pwd stand for and what does it do in bash

A

present working directory
it will show you the directory you are currently working in

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

what does cd stand for and what is it used for in bash

A

change directory
it will move you to the specified directory

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

what does mkdir stand for and what is it used for in bash

A

make directory
it makes a new directory

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

what does ls stand for and what is it used for in bash

A

list the content of the present directory

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

what does touch stand for when entered before a custom string in bash and what is it used for

A

touch + <string> will generate a new file in the current directory and specifically it will check to see if a file with this name exists in this directory. If not, it makes a new empty file with this name. If it does exist it updates the "last modified" timestamp on the file.</string>

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

When creating a new file in a directory in bash what should be added to the front of that file to make it hidden by default

A

. a period at the beginning of the file name will make it hidden. ex touch .hidden

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

when adding flags to a command like li for list in bash how many flags can you add and what order do they need to be in

A

you can add as many as you would like and they do not need to be in a specific order. ex
$ ls -l
$ ls -al
$ ls -la
all of the above will work.

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

does hidden prevent the bash from seeing the file entirely

A

No. using flags like list will only show non hidden files but flags like -a will show them

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

What is a flag for a command in bash

A

These act as options for the command. It allows you to get a specific kind of detail or functionality out of a command

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

in bash when you see a ~ (tilde) symbol what is it referencing? and how can it be used in bash

A

the ~ tilde represents the originating directory in bash and using it with commands like cd will direct you to that directory

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

how do you go up in the directory in bash

A

cd .. will send you up 1 in the directory

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

what is the difference between a relative path and an absolute path in bash

A

A relative path is based on bash’s current directory and allows you to easily access directory’s relative to your location. A absolute path can be used anywhere and contains the full path.

ex. relative path ~Desktop/NucampFolder
ex. absolute path cd c:/Users/<username>/OnceDrive/NucampFolder</username>

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

what can the up and down arrow be used for in bash

A

up will take you to your last used command and down will take you to the most recent. This is logged as a list so you are navigating up and down the list of recently used commands

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

name 3 ways to find a recently used bash command

A

up and down arrows
$history
ctrl+r to search

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

How do you add JavaScript to an HTML page?

A

Using the

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

How can you prevent JavaScript code from running immediately when the page loads?

A

By wrapping it in a function declaration

17
Q

What’s the syntax for creating a function in JavaScript?

A

function functionName() { // code here }

18
Q

How can you call a JavaScript function from an HTML button?

A

Using the onclick event handler, e.g., <button></button>

<body>
<button>Click Me</button>

<script>
function sayHello(){
                alert("Hello World!");
            }
</script>

</body>
19
Q

What’s the purpose of the <!DOCTYPE html> declaration?

A

It specifies that the document is using HTML5

<!DOCTYPE html>

<html>
<head>
<meta></meta>
<title>JavaScript Hello World</title>
</head>
<body>
<button>Click Me</button>

<script>
function sayHello(){
                alert("Hello World!");
            }
</script>

</body>
</html>
20
Q

What terminates statements in JavaScript and what is a statement

A

Statements are terminated with a ; (semicolon)
Statements are instructions to the computer

ex. let myScore;
is a statement that says. Create a variable named myScore

21
Q

What is the difference between the LET and CONST declarations in JavaScript

A

LET is used for variables where the values could be reassigned
CONST is used for variables where the values will not, can not and should not be reassigned.

22
Q

What is a declaration in JavaScript still seen today that should not be used moving forward based on best practice established with a change in 2015 that brough in new declarations?

A

VAR is a declaration you may see still today in legacy code but you should no longer use since CONST and LET have been added in 2015

23
Q

in JavaScript what is the difference between NULL and UNDEFINED

A

NULL is an empty / non-existent value, intentional absence of a value
UNDEFINED is a value given to variables that have been declared but not initialized

NULL - Let x = null;
UNDEFINED - Let x;

24
Q

JavaScript is a dynamically types language. What does this mean?

A

a variable can be of any data type and can be changed to another data type during execution.

25
Q

What are the primitive javascript data types?

A

Number:
This data type is used to represent both integer and floating-point numbers.
String:
This data type is used to store text or a sequence of characters. We use single quotes, double quotes, or backticks to denote a string.
Boolean:
This data type represents logical values. It can only be true or false.
Null:
This data type represents the intentional absence of any object value. It has only one value: null.
Undefined:
This data type is assigned to a variable that has been declared but has not been assigned a value.

26
Q

what operator can be used to check a data type in javascript

A

typeof

ex.
let age = 30;
console.log(typeof age);

27
Q

In JavaScript what is a function and what does it do

A

A function is a way to write reusable code. This code lives in one place and you can use it elsewhere as many times as you like.

28
Q

what is a function Declaration in javascript

A

A parameter list is a local variable named after whatever if put in the ( ) of the function. E.x
function sayWord(Word){
alert(word)
}

Word is a variable that is declared without let or const. It only exists inside the function and its automatically deleted when the function ends.

29
Q

In a javascript function there is a local variable. what does the word local refer to?

A

The variable is created inside the function and its localized to that function only and cannot be referenced outside of it

30
Q

What is does it mean to pass a function with an argument in Javascript ?

A

It means that you are passing an argument (value) to a function.
When a function is called, the variables declared inside the function from the parameter list receive their values from the function call’s argument list.

function sayWord(Word){
alert(word);
}

sayWord(‘rutabaga’);
the above line is passing the sayWord function an argument of ‘rutabaga’ and this is where (word) gets its value.

31
Q

How many arguments can you pass to a function in Javascript?

A

The number of arguments you can pass to a function is based on the number of declarations in the function.
ex.
function getArea(width,height){
alert(width * height);
}

The above function needs 2 arguments to run. The function has 2 declarations so 2 arguments can be passed like the example below.
getArea(8,9);

32
Q

How does the return keyword help functions and Javascript and how many return does a function have?

A

Functions always returns a single value. if you do not provide that value, it returns undefined. when you use return in a function you can use that returned value in your code to continue working on it.
Ex.
function getArea(width,height){
return width * height;
}

let area = getArea(3,4);
alert(area);
Above we are returning the area of 2 arguments and assigning it to the variable called area and using it on the next line to fire an alert.

33
Q

When you return a value where does it go in the code?

A

The value is returned to where the function was called in your code and following that line you will be able to use it.
Ex.
function getArea(width,height){
return width * height;
}

let area = getArea(3,4);
alert(area);
above alert(area); was able to access this immediately below the line that called the function. If this alert was above it it would not have a value.

34
Q

In JavaScript what is the difference between === which is a strict equality and == which is a loose equality?

A

===
will not handle implicit type conversion
==
will handle implicit type conversion.
ex.
5===’5’ will evaluate to false
5==’5’ will evaluate to true
the implicit type conversion is done by Javascript and its able to make a agreeable assumption that this string does contain a number and when converted to a number it does equal 5.

35
Q

what does null === undefined evaluate to? and what does null == undefined evaluate to?

A

null === undefined , false
null == undefined, true

36
Q

what are the 6 falsy values in javascript?

A

false
null
undefined
empty string
NaN
0

37
Q

How does the logical AND: && operator work in javascript

A

&& tests if the left operand is truthy or falsy. If falsy then it will return the left operands value and if its thruthy then it returns the right operand. If both operands are truthy it returns the last truthy value.