diff --git a/problems/countNumbers.js b/problems/countNumbers.js index 3a86643..3230ecd 100644 --- a/problems/countNumbers.js +++ b/problems/countNumbers.js @@ -12,9 +12,18 @@ * returns { 99: 2, 11: 1, 12: 1, 13: 1, 58: 1 } */ -function countNumbers() { - +function countNumbers(arr) { + let result ={}; + for (let i =0; i b.population ? -1 : 1; + } + let sortedArray = arr.sort(sortCriteria); + let onlyCountryNames = sortedArray.map(function(el) { + return el.country; + }) + return onlyCountryNames; + } -} module.exports = getCountriesSortedByPopulation diff --git a/problems/isOdd.js b/problems/isOdd.js index e93efee..266a88c 100644 --- a/problems/isOdd.js +++ b/problems/isOdd.js @@ -9,8 +9,11 @@ * ex: isOdd(75); // true */ -function isOdd() { - +function isOdd(n) { + if(n % 2 === 0){ + return false + } + return true } module.exports = isOdd diff --git a/problems/numberOfDigits.js b/problems/numberOfDigits.js index a90ca53..2d6bf71 100644 --- a/problems/numberOfDigits.js +++ b/problems/numberOfDigits.js @@ -7,8 +7,9 @@ */ -function numberOfDigits() { - +function numberOfDigits(n) { +let digits = new String(n) +return digits.length } module.exports = numberOfDigits diff --git a/problems/removeEvenStrings.js b/problems/removeEvenStrings.js index b5e8052..4b6ee1f 100644 --- a/problems/removeEvenStrings.js +++ b/problems/removeEvenStrings.js @@ -19,8 +19,14 @@ * returns: [] */ -function removeEvenStrings() { - +function removeEvenStrings(arr) { + let newArray =[] + for (let el of arr){ + if(el.length %2 !==0){ + newArray.push(el) + } + } +return newArray } module.exports = removeEvenStrings diff --git a/problems/removeNumbersAtOddIndices.js b/problems/removeNumbersAtOddIndices.js index 94d03a0..835faa1 100644 --- a/problems/removeNumbersAtOddIndices.js +++ b/problems/removeNumbersAtOddIndices.js @@ -10,8 +10,15 @@ * ex: removeNumbersAtOddIndices([5, 4, 3, 2, 1]); * returns: [5, 3, 1] */ -function removeNumbersAtOddIndices() { +function removeNumbersAtOddIndices(arr) { + let newArr = []; + for(i = 0; i el %2 ===0) + } module.exports = removeOddNumbers \ No newline at end of file diff --git a/problems/removeVowels.js b/problems/removeVowels.js index be7edc6..5b56788 100644 --- a/problems/removeVowels.js +++ b/problems/removeVowels.js @@ -14,8 +14,27 @@ * */ -function removeVowels() { +function removeVowels(str) { + let output = ""; + for (let i = 0; i < str.length; i++) { + if ( + str[i] === "a" || + str[i] === "e" || + str[i] === "i" || + str[i] === "o" || + str[i] === "u" || + str[i] === "A" || + str[i] === "E" || + str[i] === "I" || + str[i] === "O" || + str[i] === "U") { + str.slice(i, i + 1) + } else { + output += str[i] + } + } + return output; + } -} module.exports = removeVowels diff --git a/problems/sevenBoom.js b/problems/sevenBoom.js index a77a8f9..d084f12 100644 --- a/problems/sevenBoom.js +++ b/problems/sevenBoom.js @@ -11,7 +11,20 @@ * 17 is also replaced with 'BOOM' because it contains a 7. */ -function sevenBoom() { +function sevenBoom(n) { + let answer = []; + for(i = 1; i<=n ; i++) { + let digitToString = i.toString(); + if( i % 7 === 0 ) { + answer.push('BOOM'); + } + else if(digitToString.includes('7')) { + answer.push('BOOM'); + } else { + answer.push(i); + } + } + return answer; } diff --git a/problems/smallest.js b/problems/smallest.js index 931bf25..2a39c01 100644 --- a/problems/smallest.js +++ b/problems/smallest.js @@ -14,8 +14,12 @@ * returns 1 (does not matter if it is the first or second 1) */ -function smallest() { - +function smallest(nums) { + let smallest =nums[0] + for( let i =0; i<= nums.length -1; i++) + if (nums[i]< smallest) + smallest = nums[i] + return smallest } module.exports = smallest