Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

array change javascript

function solution(inputArray) {
    let counter = 0;
    inputArray.reduce((a, b) => {
        if (a >= b) {
            const diff = a + 1 - b;
            counter += diff;
            return a + 1;
        }
        return b;
    });
    return counter;
}
 
PREVIOUS NEXT
Tagged: #array #change #javascript
ADD COMMENT
Topic
Name
5+4 =