Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

// JAVASCRIPT Language please answer questions after the // console.log(-------------- Data and Variables ---------------) // declare two constants and assign them floating point values //

// JAVASCRIPT Language please answer questions after the //

console.log("-------------- Data and Variables ---------------")

// declare two constants and assign them floating point values

// declare two variables and assign them floating point values

// calculate the average of those values and output to the console using a *template literal*

// (the `` notation)

// for example, "The average is 3.4"

console.log("-------------- Control Structures ---------------")

/* write if statements to print out whether each of the following values is "false-y" (evaluates to false)

positive number, negative number, zero

empty string "", blank string " "

null, NaN, Infinity, undefined

an undefined variable*/

if (16) console.log("16 is true");

if (-16) console.log("-16 is true");

if (0) console.log("0 is true");

if (NaN) console.log("NaN is true");

// write a for loop that prints the numbers from 0 to 10

for (let i = 0; i < 10;i++){

console.log(i);

}

let list = [23, 14, 15, 66, 22];

for (let item of list){

console.log(item)

}

// write a while loop that counts down from 20 to 0 by threes

while(i == 20, i--){

}

console.log("-------------- Functions ---------------")

// write a function that takes two parameters and returns their sum

function sum(a, b)

{

return a + b;

}

// call it with one argument and print the result

let result = fn(16);

console.log(result)

// call it with two arguments and print the result

// call it with three arguments and print the result

console.log("-------------- Arrays ---------------")

// declare an array of 5 integer values ranging from -10 to 10

const line = [3, -2, 10 , 6, -7]

// change the third value in the array to -17 and print the array

list[2] = 13;

console.log(list)

// write a for...in loop over the array and print each value (each value that is "bound" to the specified variable)

for(let item in list)

{

console.log(item);

}

// write a for...of loop over the array and print each value

// use the array.sort method to sort the array and print it

// use the array.join method to create a comma-separated string from the array and print it

console.log("This script is done.")

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_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

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

Get Started

Students also viewed these Databases questions

Question

What is operating capital, and why is it important?

Answered: 1 week ago

Question

List behaviors to improve effective leadership in meetings

Answered: 1 week ago