From c38ec9d78895fb0ed1d8fa36c97b8c4bab2a751b Mon Sep 17 00:00:00 2001 From: jrogergordon <103604859+jrogergordon@users.noreply.github.com> Date: Wed, 29 Nov 2023 16:51:09 -0500 Subject: [PATCH] first 10 odd multiples in js Function to find the first 10 odd multiples of an integer in js --- first 10 odd multiples in js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 first 10 odd multiples in js diff --git a/first 10 odd multiples in js b/first 10 odd multiples in js new file mode 100644 index 0000000..9327b23 --- /dev/null +++ b/first 10 odd multiples in js @@ -0,0 +1,16 @@ +function first10Odd(num) { + let arr = []; + if(num % 2 === 0) { + return false + } else { + arr.push(num); + } + let curr = num; + while(arr.length < 10) { + curr = curr + num; + if(curr % 2 !== 0) + { + arr.push(curr); + } + } +}