Return Negative | JavaScript - Codewars

preview_player
Показать описание
In this video, we're solvint the "Return Negative" problem from #Codewars in #JavaScript

Solution:: Return Negative
Рекомендации по теме
Комментарии
Автор

i just started js, on the if statement you dont need the {} for the code block??

soulforthekindheart
Автор

Hi! I've been using your videos to help me go through the code wars katas. Thank you! I think a more elegant/ one line solution to this is:

return -Math.abs.(num)

It takes the absolute value of num and makes it negative

joshualevan