I want to reverse a number t following the tutorial.First I have passed a number as a parameter. I have converted the number to string with to String function. Then I used split("").reverse().join("") to reverse the number. My code is as follows:
<script type="text/javascript">
function reverse_the_string(num) {
num = String(num);
// str = num.toString;
num.split("").reverse().join("");
return;
}
console.log(reverse_the_string(56789));
</script>
However I get an error undefined? Can anyone explain what is the wrong?
return String(num).split("").reverse().join("");