Ok, so chrome console works same on all the pages.
I opened the console by pressing (F12) key on keyboard.
Then i wrote this code :
var remainder = ;
var squareroot = Math.floor(Math.sqrt(num))
The logic that goes behind this code is :
1) When i wish to find out whether a number is prime or not, what i have to do is check its divisibility by all the numbers which are less than squareroot of that number.
2) If a number has squareroot in decimal values(which most of the numbers have), then i just convert that into integer by
3) If the number is not divisble by any of the numbers less than its squareroot, it is a prime number.
4) So, in the code, i declared an empty array
"remainder" first and then, i calculated the squareroot of the num and converted it into integer. And then, i started the loop with initial value of 2 because if it initializes with 1, num will always be divisible by 1.
5) Now, num is divided and by all the number in loop, and the remainder is pushed to remainder array.
6) If the num is divisible by any of the values in loop, the remainder array will have 0 as one of its elements.
7) Thus, if remainder array contains 0 function
isPrime() returns false else it returns true i.e the number is prime.
I have checked for several test cases and function works all the time.
But when it is inside the
sumPrimes() it does not work.