Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Explain this code: var numArray = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] var primeArray = [] function isPrime(number = []){ for

Explain this code:

var numArray = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

var primeArray = []

function isPrime(number = []){

for (var i = 0; i < number.length; i++) {

if (number[i] === 2 && number[i]!= 1) {

primeArray.push(number[i])

console.log("This is a prime number");

console.log(number[i]);

}

else if (number[i] % 2 != 0 && number[i]!= 1){

primeArray.push(number[i])

console.log("This is a prime number");

console.log(number[i]);

}

else{

console.log("This is not a prime number")

console.log(number[i]);

}

}

}

isPrime(numArray)

console.log(" ")

console.log("Prime Array")

console.log(primeArray)

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

Relational Database Technology

Authors: Suad Alagic

1st Edition

354096276X, 978-3540962762

More Books

Students also viewed these Databases questions

Question

Define the term intellectual property and describe its importance.

Answered: 1 week ago

Question

What is Taxonomy ?

Answered: 1 week ago

Question

1. In taxonomy which are the factors to be studied ?

Answered: 1 week ago

Question

1.what is the significance of Taxonomy ?

Answered: 1 week ago

Question

What are the advantages and disadvantages of leasing ?

Answered: 1 week ago

Question

2 The main characteristics of the market system.

Answered: 1 week ago