e4 = prompt("Enter the five favorite sports", "hockey,football,basketball,tennis,golf");
e4 = e4.split(",")
for (var i = 0; i < e4.length; i++) {
if (e4[i] == "football") {
e4[i] = "soccer";
}
}
e5 = prompt("Enter extra sport", "formula 1");
e4.push(e5);
for (var i = 0; i < e4.length; i++) {
e4[i] = e4[i].toUpperCase();
}
e4.sort();
This is my lines of code that would print out like this
["BASKETBALL", "FORMULA 1", "GOLF", "HOCKEY", "SOCCKER", "TENNIS]
however, what I want to print out is in format such as this:
BASKETBALL
FORMULA 1
GOLF
HOCKEY
SOCCER
TENNIS
and new lines of other code would start here.
I'm from C++ so im aware of \n, but how would you format it like that so it is indented like that above and creating new lines everytime it goes through elements in array?