Question
Javascript Understanding Each question deals with your understanding of javascript This section is you explaining code. Write your explanation and submit it from the answer
Javascript Understanding
Each question deals with your understanding of javascript
This section is you explaining code. Write your explanation and submit it from the answer textbox.
Try to be as technical as you can with your explanation, but the important part here is to demonstrate your understanding of javascript.
Question 1
What is newArr?
explain why newArr contains those values
var arr = [2, 4, 6, 8];
var newArr = [];
var a = 0;
var b = 0;
for (var i = 0; i < 4; i++) {
a = arr[i];
b = arr.length - i;
newArr.push(a + b);
}
Question 2
Upon invoking/calling the Bill function, what parameter value do we need to pass to this function, in order to console.log("Got Ya!)"
Explain what happen to the values for it to get to the console.log
var bill = function(amount){
if(amount > 10 && amount <100){
return amount + tax(amount, 1);
}
else if(amount >= 100){
return amount + tax(amount, 2);
}
else {
return amount;
}
}
var tax = function(price, bracket){
if(bracket === 1){
return price * 0.1;
}
else if(bracket === 2){
console.log("Got ya!")
return price * .2;
}
else {
return 0;
}
}
Question 3
what's the difference between the two sets of curly braces?
function doSomething() {
var a = 5;
var b = 10;
}
var something = {
a: 5,
b: 10
}
Question 4
What is the name and salary when the script runs giveRaise(p)?
Explain what happen to the values for the name and salary you chose?
function getP() {
var person = {};
person.fName = 'Hector';
person.lName = 'Arias';
person.salary = 50000;
return person;
getP2(person);
}
function getP2(name) {
giveRaise(name);
}
function giveRaise(emp) {
emp.fName;
emp.salary * 2;
}
var p = getP();
giveRaise(p);
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started