DEV Community

loading...

python to javascript

yurrey profile image abdelwahed ・1 min read

Good morning gorgeous friends;
is there any equivalent of this python expression in javascript
l = [1, 2, 5, 4, 8]
n = 5
print('yeah' if n in l else 'no')

Thanks

Discussion

pic
Editor guide
Collapse
darkwiiplayer profile image
DarkWiiPlayer

EDIT: Never mind, the code below actually does something completely different. This is why I hate javascript ffs.

console.log(n in l ? "yeah" : "no")
Enter fullscreen mode Exit fullscreen mode
Collapse
kobelobster profile image
Theo Tzaferis

console.log(l.includes(n) ? 'yeah' : 'no');