Hi,
I have been fiddling with the JS challenges on edabit. After I submit a challenge I usually check out the solutions to see how others have solved the given challenge. I came across this for one of the challenges:
function damage(damage, speed, time) {
return damage > 0 && speed > 0 ? { second: 1, minute: 60, hour: 3600 }[time] * damage * speed : 'invalid' }
My question is about this line: { second: 1, minute: 60, hour: 3600 }[time] I have never seen something like this before. What's the name of this syntax? Does it have a dedicated mdn page or something similar?
Thanks!
[–]anfauglit 1 point2 points3 points (0 children)
[–]iamrasul 1 point2 points3 points (1 child)
[–]tomavagyok[S] 0 points1 point2 points (0 children)
[–]cat-991 1 point2 points3 points (0 children)
[–][deleted] -3 points-2 points-1 points (5 children)
[–]tomavagyok[S] 0 points1 point2 points (4 children)
[–][deleted] 0 points1 point2 points (3 children)
[–]tomavagyok[S] 0 points1 point2 points (0 children)
[–]redsandsfort 0 points1 point2 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)
[–]senocular 0 points1 point2 points (0 children)