Answered step by step
Verified Expert Solution
Question
1 Approved Answer
var items = [one, 32, true, two, 33.1, 45, world, false]; program in JS that gives the total of summation for numbers only. In this
var items = ["one", 32, true, "two", 33.1, 45, "world", false];
program in JS that gives the total of summation for numbers only.
In this case, it will add only 32, 33.1 and 45 as an example and should not try to add when it gets non numeric item.
Hint:
var total = 0;
for (var i = 0 ; i < items.length ; i++) {
if (typeof items[i] === 'number') {
//your code here to accumulate the summation on total
}
}
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