Ready Monetized Wordpress Website

Friday, May 31, 2019

How can I make this JavaScript code work?

I want to return the total number of characters in the array, but my code doesn't work. Can you fix it for me? Thanks.

function total_characters(array) {

sum = 0

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

sum = sum + array[i].length

return sum

}

}

console.log(total_characters(['adios', 'bye', 'ciao']))

submitted by /u/LovelyLionLily
[link] [comments]

from web_design http://bit.ly/2IbZcnE
via IFTTT

No comments:
Write Your Comments

Ready Monetized Blogger Gaming Website