I need to know this four-line of code what’s working 1/while loop what’s works 2/if condition what’re works 3/this array decrement what work 4/this j increment what’re works
blow the whole code
function change(x, times) {
for(let i = 0; i < x.length; i++) {
let j = 1;
//while loop what's work
while (j <= times) {
//if condition what work
if (i >= j && i < x.length-j) {
//this array decrement what's work
x[i]--;
}
//this j increment what's work
j++;
}
}
return x;
}
let result = change([3, 3, 3, 3, 3, 3, 3],1)