Smallest Common Multiple - Please help, browser crashes!

Smallest Common Multiple - Please help, browser crashes!
0.0 0

#1

I don’t know what to do. I started this challenge, have just written some code. When I tried to test the first part of the code the browser crashed. However, as soon as I get to the page of this challenge again, after a few seconds my browser freezes. This doesn’t happen with any of the other pages of the site. I don’t click Run Tests, I just open the page. I can’t even change anything in my code, as it’s the most likely a cause of the problem.

Please help me :frowning:


#2

maybe you have an infinite loop or something like that.
test it on node.js.


#3

I guess I do, but how can I change it if it runs as soon as I open the page?
I have no idea what node.js is.


#4

node.js is just a runtime for javascript. you can think of it as a compiler. so instead of running a js grogramm on the browser you can run it on your terminal.

can you share your code with as?


#5

I know it is not right, but I have no idea how to change it on FCC site now. Because the browser freezes immediately after I enter the page. :frowning:


#6

Remove your code from browsers url


#7

I think the problem is in your second for loop;
try this

for (var b=arr[1]+1; b<arr[0]; b++){
between.push(b);
}


#8

in your code as arr[0] is greater than arr[1] and as you do b++ then b>arr[1] will be true for ever, then you will have an infinite loop


#9

Thanks for all the suggestions, guys. I would change my code, but I have no idea how to change it since the whole browser freezes when I try to. How could I change the code from url, @jenovs? That seems weird


#10

Do your solution url (address) looks like this?:

https://www.freecodecamp.com/challenges/smallest-common-multiple#?solution=function%20smallestCommons(arr)%20%7B%0A%0A%20%20%20%20var%20isDivisible%20%3D%20true%3B%0A%20%20%20%20%0A%20%20%20%20arr.sort()%3B%0A%0A%20%20%20%20for%20(var%20i%20%3D%20arr%5B1%5D%3B%20%3B%20i%20%2B%3D%20arr%5B1%5D)%20%7B%0A%20%20%20%20%20%20%20%20isDivisible%20%3D%20true%3B%0A%20%20%20%20%20%20%20%20for%20(var%20j%20%3D%20arr%5B0%5D%3B%20j%20%3C%20arr%5B1%5D%3B%20j%2B%2B)%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20if%20(i%20%25%20j%20!%3D%3D%200)%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20isDivisible%20%3D%20false%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20if%20(isDivisible)%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20return%20z%3B%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%7D%0A%20%20return%3B%0A%7D%0A%0A%0A%2F%2F%20smallestCommons(%5B23%2C18%5D)%3B

If yes, remove # and everything that follows it.


#11

@jenovs It actually doesn’t. It’s plain
https://www.freecodecamp.com/challenges/smallest-common-multiple :frowning:
I feel so desperate.


#12

#13

Thanks @jenovs. This solved my issue, and actually made me learn something about Developer Tools!
I am giving you brownie points on chat :slight_smile:


#14

I am having the same problem but using a Mac Pro. How do I do same in Safari?


#15

Just use the safari dev tool (Option+Command+I) then there should be storage tab.