i’ve searched so many videos to find the explanation of the math and you are the only one whose has explained it so well.
@angeloloria65443 жыл бұрын
great video, thank you for this breaking down the math for my own sake reversing a number, ex. 123: 1) use the modulo operator to divide by 10 and return the last decimal space, which will be 3 in this case (123/10 == 12.3) 2) use Math.floor, which will round down and return the nearest whole number, which will be 12 3) use the modulo operator in the same manner as step 1, which will return a 2 (12/10 == 1.2) 4) multiply the first number we extracted (3) times 10, to put it ahead of the second number we extracted (2) 5) add our multiplication result (30) to our second extracted number (2) to get 32. we've now reversed the last two digits of our original number (123) 6) use Math.floor on our last number, which gives us 1 7) use the modulo on that number again, which gives us 1 8) multiply our current reversed number (32) times 10 to put it ahead of our last extracted number (1) 9) add our multiplication result (320) to our last extracted number (1) to get 321, our reversed number
@athirahasri97039 ай бұрын
I love this one. Thank you so much!
@UlianaSarkisova Жыл бұрын
Thank you for such an easy to understand explanation!
@pweezy0012 жыл бұрын
Awesome video, thanks for sharing!
@pinkhairblackman81413 жыл бұрын
since the number will be a palindrome return reverse===x; will confirm if the number is the same since its a palindrome when reversed. math.floor(i/10) decrements until i>=1 is false in loop
@StockWithSayee Жыл бұрын
Great Video :)
@felipegarcialopez37013 жыл бұрын
Great video!
@jianqiuwang87982 жыл бұрын
why i >= 1 ? can someone explain it ?
@dannycho22872 жыл бұрын
on line 8, we have the following: for(let i = x; i >= 1; i = Math.floor(i/10)) {...} Now, take an input of 121 as an example. The first iteration of the for loop takes us to i = 121; i is still greater than or equal to 1; i becomes Math.floor(121/10), which is 12. The second iteration of the for loop takes us to i = 12; i is still greater than or equal to 1; i becomes Math.floor(12/10), which is 1. The third iteration of the for loop takes us to i = 1; i is still greater than or equal to 1; i becomes Math.floor(1/10), which is now 0. Since i is now NOT greater than or equal to 1, we come to an end of the for loop. By this time, we already have a reverse version of the number 121.
@jianqiuwang87982 жыл бұрын
@@dannycho2287 hello Danny, thank you so much for the explanation, I really appreciate it!
@parthgoswami3221 Жыл бұрын
@@dannycho2287 great explanation! thank you
@rajbannasa76622 жыл бұрын
thank you so much sir
@josey7002 жыл бұрын
Good day! Great content though the font size is just perfect for coding not so much for presenting
@sarasalvatierra71983 жыл бұрын
you are my savior
@dshl21 Жыл бұрын
thankyou
@Valer0n072 жыл бұрын
What if an input = 10 or 1000 or 200? This solution will not generate a correct reversed output. But technically it will return a corect answer - false. This input (1234567899) also breaks this algorithm.
@iharisyousaf Жыл бұрын
What do you suggest for these cases
@rawstrife97623 жыл бұрын
GOAT!
@Mikeishere12342 жыл бұрын
make more of these please
@athraafaraj83873 жыл бұрын
Very help
@iharisyousaf Жыл бұрын
It fails in case of 10
@RichardYoung114 жыл бұрын
bring back the lofi!
@ThinkFWD4 жыл бұрын
I just brought it back ! :), release a new vid with it. let me know if you have any question you want solved/explained