mardi 22 septembre 2020

Loop through array and replace value on condition in Javascript

My array and pseudo code are as follows. I do need help with replacing values with stirng on condition. I tried below but can't move on.

var = [5000, 2000, 4030, 1100];

for (var i = 0; i < arR.length; i++) {
    if (arR.includes >= 5000) {
        (‘senior’);
    } else if (arR.includes >= 2000) {
        console.log(‘mid’);
    } else {
        (‘junior’);
    }
}

Expected result: var = [senior, mid, mid, junior];

Aucun commentaire:

Enregistrer un commentaire