i have array in javascript
var = [1,2,3,4,5,"4","12","2",6,7,"4",3,"2"];
my questions are
how split array change, (comma) ";"
how return number of strings in array return total value regardless of variable type.
how return average value (regardless of variable type again)
answering question 1
1.convert string
var x=a.tostring();
2.perform global replace
var y= x.replace(/,/g,";");
3.this gives "1;2;3;4;5;4;12;2;6;7;4;3;2"
for question 2 use a.length
method.this give total number of elements.i'm not sure string elements part.
Comments
Post a Comment