I'm trying to figure out how to push an additional value to an array if my index.Of is equal or greater than 0. However the below code doesn't seem to work, I don't get any errors and I've checked the index.0f and it always equals 0.
var groups = ['a,b,c,']
function myfunction () {
if (groups.indexOf('a,b,c,') >= 0) {
groups.push('d')
}
}
console.log(groups);
Aucun commentaire:
Enregistrer un commentaire