-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwhat_a_mess.js
35 lines (32 loc) · 959 Bytes
/
what_a_mess.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
let someDoDad = ['green', 'red', 'bar']
let someOddThing = ['one', 'two', 'baz']
let someOtherThing = { type: '123abc' }
const strangeFunc = () => {
someOddThing &&
(someDoDad.includes(
'foo',
) ? (
console.log('hello')
) : someDoDad.includes(
'bar',
) ? (
return
console.log('world')
) : someDoDad.includes(
'baz',
) ? (
console.log('alice')
) : someOtherThing.type == '123abc' ? (
console.log('bob')
) : someOddThing.includes('foo') ||
someOddThing.includes('bar') ||
someOddThing.includes('baz') ? (
console.log('carol')
) : (
console.log('This isn\'t working')
))
}
strangeFunc()
// What will this funciton output?
// Technically, it works...but what's wrong with it?
// Can you rewrite this without ternaries?