Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved 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

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Pro Database Migration To Azure Data Modernization For The Enterprise

Authors: Kevin Kline, Denis McDowell, Dustin Dorsey, Matt Gordon

1st Edition

1484282299, 978-1484282298

More Books

Students also viewed these Databases questions

Question

Distinguish between accountability and interperiod equity.

Answered: 1 week ago

Question

How would we like to see ourselves?

Answered: 1 week ago

Question

=+1 Where are the best places in the world to live (and work)?

Answered: 1 week ago

Question

=+Are you interested in working on global teams?

Answered: 1 week ago

Question

=+Do you want to work from home?

Answered: 1 week ago