+ 3

Check to Array

I have a Array. If a word is in this Array already it will not add it to Array but If it is not in this Array, it will add it to Array How Can I Write It?

2nd Jun 2017, 4:33 AM
Serhat Merak
Serhat Merak - avatar
2 ответов
+ 4
Use indexOf for checking if (arr.indexOf (word) === -1) arr.push (word)
2nd Jun 2017, 4:35 AM
Calviղ
Calviղ - avatar
+ 1
Thank you 😊
2nd Jun 2017, 4:39 AM
Serhat Merak
Serhat Merak - avatar