0
PLEASE SOLVED MY PROBLEM!! (SOLVED)
How to check and call all items in array. example: var player= prompt('select one options (rock, scissors, paper)') ; var item = ['rock', 'scissors', 'paper'] ; if(player == item[0] | player == item[1] | player == item[2]) { alert('test') ; } My Question is How to write the code above to make it more concise??? https://code.sololearn.com/WpM35P2Kwdri/?ref=app
2 Respostas
+ 3
You can use includes method
if( item.includes(player) ) alert('test');
+ 2
...
if(item.some(a => a == player))
...