Tell us what’s happening:
I have no idea why this does not pass the tests, as when I use console.log the results are the same as what it provided.
Your code so far
function convertHTML(str) {
var arr = ;
var Array = str.split("")
for (var i = 0; i < Array.length; i++) {
if (Array[i] == “&”) {
arr.push("&");
} else if (Array[i] == “<”) {
arr.push("<");
} else if (Array[i] == “>”) {
arr.push(">");
} else if (Array[i] == ‘"’) {
arr.push(""")
} else if (Array[i] == “’”) {
arr.push("'")
} else {
arr.push(Array[i]);
}
}
var results = arr.join("");
return results;
}
function convertHTML(str) {
// :)
var arr = []
var Array = str.split("")
for (var i = 0; i < Array.length; i++) {
if (Array[i] == "&") {
arr.push("&");
} else if (Array[i] == "<") {
arr.push("<");
} else if (Array[i] == ">") {
arr.push(">");
} else if (Array[i] == '"') {
arr.push(""")
} else if (Array[i] == "'") {
arr.push("'")
} else {
arr.push(Array[i]);
}
}
var results = arr.join("");
return results;
}
console.log(convertHTML('Stuff in "quotation marks"'));
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.113 Safari/537.36
.
Link to the challenge: