Get the sum from ASCII array

Write a function that accepts an array as argument. The function should loop through the array element and accumulate the sum of ASCII value of each character in each element and return the total.

function ASCIISuma(array) {
    let suma = 0;
    for(let i = 0; i < array.length; i++) {
        let char_code = array[i].charCodeAt(0);
        suma += char_code;
    return suma;

enter image description here

It always shows me incorrect results.

Read more here:

Content Attribution

This content was originally published by Yaroslav Yatsyk at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: