- Fork this repo
- Clone your fork
- Fill in your answers by writing in the appropriate area, or placing an 'x' in the square brackets (for multiple-choice questions).
- Add/Commit/Push your changes to Github.
- Open a pull request.
What of the following are JavaScript Data Types?
Select all that apply:
[X] Strings
[X] Booleans
[X] Undefined
[X] NaN
[X] Integers
[X] Arrays
[X] Null
Explain what is a REPL, and why is it important for us as developers and help with debugging?
REPL is a live tool used to write code and see the output of your code at the same time.
Given the Following Array
var foods = [ ["apple","banana","strawberry"], ["pizza","fries","hamburger"] ];
Create a For Loop that outputs the following string for each piece of fruit in the console. "I want to eat a [fruit]"
for(i = 0; i > 0; i++){
function() {
var prompt("I want to eat a" + " " + foods[0])
}
}
Given the Following Array
var foods = [ ["apple","banana","strawberry"], ["pizza","fries","hamburger"] ];
How would I go about accessing the string "pizza" in the above array?
function pizza() {
console.log([1]);
}
Describe the rules of scope in JavaScript.
Your Answer:
Scope is the container created to house different areas of your code to ensure the JavaScript behaves the way you want it to.
Define an object and store it in a variable pizza
. The object should have 2
properties: a temperature (set to 70), and a method called bake
. When called,
this method should set the pizza's temperature to be 300. Note: you may not use
the variable pizza inside your method.
Your Answer:
var pizza = myObject;
var myObject = {
temperature:
bake: function () {
console.log("300 degrees f/c.");
}
}
Define a global variable instructor and set it equal to your Squad Instructor's Name. Then, define the same as a local variable instead.
Your Answer:
var squadLeader = "Matt";
function(squadLeader){
var squadLeader("Matt");
}
What are the differences between calling and referencing a function? Please provide examples of each.
If you want to execute the function now the call it. If you want to use it later then you reference it.
Using the object literal notation, Define an object called student and give it the properties (your attributes) of name, age, and a method sayHello, that outputs "Hi, my name is [your_name]".
Your Answer:
var student = {
name: [];
age: "22";
sayHello: function() {
var name = prompt("Enter your name.");
console.log("Hi, my name is" + " " + name);
}
console.dir(student);
}
What is the difference between synchronous and asynchronous program execution?
Select all that apply:
[X] Synchronous code runs at an even pace, asynchronous code runs with uneven pacing.
[] Synchronous code runs all at the same time, asynchronous code runs completely randomly
[X] Synchronous code runs in order (as appears in the source), asynchronous code may run at a later time.