DEV Community

abdelwahed
abdelwahed

Posted on • Updated on

python to javascript

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

Top comments (2)

Collapse
 
kobelobster profile image
Theo Tzaferis • Edited
console.log(l.includes(n) ? 'yeah' : 'no');
Enter fullscreen mode Exit fullscreen mode


`

Collapse
 
darkwiiplayer profile image
𒎏Wii 🏳️‍⚧️ • Edited

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