Alexander Davies Alexander Davies - 1 month ago 24
Node.js Question

java script for loop program, stuck

Hi so ive never done JS before and im struggling to figure out what code should go in the '??????????' space. If some one could help me it would be much appreciated. (also struggling with opening the file on the command line. I have nodejs installed and ive tried .load 'filename.js' but it dosent recognise .load)

for(var i=0; i<5; i++){
fleet[i] = new Taxi(i);
}

for(var i=0; i<fleet.length; i++){
print("Taxi with badge number " + fleet[i].badgeNumber + " is " + fleet[i].color);
}

??????????????? = "White";

for(var i=0; i<fleet.length; i++){
print("Taxi with badge number " + fleet[i].badgeNumber + " is " + fleet[i].color);
fleet[i].blowHorn()
}


this is the desired output:

>>> load("assignment.js")
Taxi with badge number 0 is yellow
Taxi with badge number 1 is yellow
Taxi with badge number 2 is yellow
Taxi with badge number 3 is yellow
Taxi with badge number 4 is yellow
Taxi with badge number 0 is White
Beep!
Taxi with badge number 1 is White
Beep!
Taxi with badge number 2 is White
Beep!
Taxi with badge number 3 is White
Beep!
Taxi with badge number 4 is White
Beep!

Answer

you can replace the below line

??????????????? = "White";

with

fleet.map((itm) => itm.color = "white");