My (JavaScript) code is so bad, I think I broke my browser! I was working on a problem to get the last digit of a number and this is what I came up with:
function getLastDigit(num) {
let newNum = num;
while (newNum > 9) {
newNum-=10;
}
return newNum;
}
It worked fine for my first several test cases, but when I put in something like getLastDigit(343243242342), the console gave me a blue arrow and wouldn’t do anything. It wouldn’t even refresh and it took a while for me to close it.
Was it just because the function was still running because it was so inefficient?