How to iterate an array in javascript
arrays, javascript, loops
Solution
Iterate over using the length property rather than a `for ... in` statement and write the array value from inside the loop.
for (var ii = 0, len = arr.length; ii < len; ii++) {
document.write(arr[ii]);
}
Problem
I have an array like `var arr = { 30,80,20,100 };` And now i want to iterate the above array and add the iterated individual values to one function return statement for example ``` function iterate() { return "Hours" + arr[i]; } ``` I had tried in the following approach ``` function m() { for(var i in arr) { s = arr[i]; } document.write(s); } ``` The above code will gives only one value i.e. last value in an array. But i want to iterate all values like ``` 30---for first Iteration 80---for second Iteraton Any help will be appreciated ```