From 147524b164dfcfd27b7c619da0cf9938b3ad2375 Mon Sep 17 00:00:00 2001 From: Senay Yakut Date: Tue, 11 Dec 2018 15:03:09 -0800 Subject: [PATCH] Create example.js --- chapter06/example.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 chapter06/example.js 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);