I can't figure out why this snippet logs false. I'm convinced it should log to true. What am I doing wrong?
var hasElb = function(string12b,char12b) {
var el = [];
for (var i = 0; i < string12b.length; i++ ) {
if (string12b[i] === char12b) {
el += char12b;
}
}
if (el[0] === char12b) {
console.log(true + " el[0] = " + el[0] + " and char12b = " + char12b);
}
else {
console.log(false + " el[0] = " + el[0] + " and char12b = " + char12b);
}
};
hasElb([1,3,5,7,9,11],7);
Aucun commentaire:
Enregistrer un commentaire