diff --git a/chapter06/example.js b/chapter06/example.js new file mode 100644 index 0000000..8c0d29b --- /dev/null +++ b/chapter06/example.js @@ -0,0 +1,14 @@ +This is another question at the book, it is also a common interview question + +Determine if a number is prime using JavaScript + +function isPrime(value){ + for(var i = 2; i < value; i++){ + if(value % i === 0){ + return false; + } + } + return value > 1; +} + +isPrime(11);