This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//function checkIfEven checks if given number consists of only even digits | |
const checkIfEvenDigit = function (number) { | |
if (number % 2 === 0) { | |
return true; | |
} else { | |
return false; | |
} | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//function sumPrimes sums all prime numbers up to the provided number | |
const isPrime = function (number) { | |
if (number <= 2) { | |
return 1; | |
} | |
for (let i = 2; i < number; i++) { | |
if (number % i === 0) { | |
return 0; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//function to find first duplicate in array | |
function firstDuplicate(nums) { | |
let MyObj = {} | |
let myArr = [] | |
for (i=0; i< nums.length ; i++){ | |
for (j=i+1; j< nums.length; j++){ | |
if(nums[i] === nums[j]){ | |
MyObj[nums[i]] = j; | |
} |
NewerOlder