I m getting values from multiple radio button and storing it into variables as a comma seperated number.
var coef = "1, 2, 3, 4";
output I want is multiplication of of all numbers;
total = 24
I m trying to implement it in javascript/jquery. Any help?
3
Answers
You could try something like this:
If array
Demo
You can solve this with
split
andreduce
if you pass in a comma separated string:If you pass in an array, you don’t need to split:
You could use
.split()
and.forEach()
methods :