Week 1 Flashcards
What does pwd stand for and what does it do in bash
present working directory
it will show you the directory you are currently working in
what does cd stand for and what is it used for in bash
change directory
it will move you to the specified directory
what does mkdir stand for and what is it used for in bash
make directory
it makes a new directory
what does ls stand for and what is it used for in bash
list the content of the present directory
what does touch stand for when entered before a custom string in bash and what is it used for
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>
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 period at the beginning of the file name will make it hidden. ex touch .hidden
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
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.
does hidden prevent the bash from seeing the file entirely
No. using flags like list will only show non hidden files but flags like -a will show them
What is a flag for a command in bash
These act as options for the command. It allows you to get a specific kind of detail or functionality out of a command
in bash when you see a ~ (tilde) symbol what is it referencing? and how can it be used in bash
the ~ tilde represents the originating directory in bash and using it with commands like cd will direct you to that directory
how do you go up in the directory in bash
cd .. will send you up 1 in the directory
what is the difference between a relative path and an absolute path in bash
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>
what can the up and down arrow be used for in bash
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
name 3 ways to find a recently used bash command
up and down arrows
$history
ctrl+r to search
How do you add JavaScript to an HTML page?
Using the
element
How can you prevent JavaScript code from running immediately when the page loads?
By wrapping it in a function declaration
What’s the syntax for creating a function in JavaScript?
function functionName() { // code here }
How can you call a JavaScript function from an HTML button?
Using the onclick event handler, e.g., <button></button>
<body>
<button>Click Me</button>
<script> function sayHello(){ alert("Hello World!"); } </script>
</body>
What’s the purpose of the <!DOCTYPE html> declaration?
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>
What terminates statements in JavaScript and what is a statement
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
What is the difference between the LET and CONST declarations in JavaScript
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.
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?
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
in JavaScript what is the difference between NULL and UNDEFINED
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;
JavaScript is a dynamically types language. What does this mean?
a variable can be of any data type and can be changed to another data type during execution.
What are the primitive javascript data types?
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.
what operator can be used to check a data type in javascript
typeof
ex.
let age = 30;
console.log(typeof age);
In JavaScript what is a function and what does it do
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.
what is a function Declaration in javascript
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.
In a javascript function there is a local variable. what does the word local refer to?
The variable is created inside the function and its localized to that function only and cannot be referenced outside of it
What is does it mean to pass a function with an argument in Javascript ?
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.
How many arguments can you pass to a function in Javascript?
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);
How does the return keyword help functions and Javascript and how many return does a function have?
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.
When you return a value where does it go in the code?
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.
In JavaScript what is the difference between === which is a strict equality and == which is a loose equality?
===
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.
what does null === undefined evaluate to? and what does null == undefined evaluate to?
null === undefined , false
null == undefined, true
what are the 6 falsy values in javascript?
false
null
undefined
empty string
NaN
0
How does the logical AND: && operator work in javascript
&& 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.