Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5,714 changes: 5,712 additions & 2 deletions package-lock.json

Large diffs are not rendered by default.

12 changes: 10 additions & 2 deletions problems/countNumbers.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,16 @@
* returns { 99: 2, 11: 1, 12: 1, 13: 1, 58: 1 }
*/

function countNumbers() {

function countNumbers(arr) {
let count = {}
for(let i = 0; i < arr.length; i++){
if (count[arr[i]]){
count[arr[i]] += 1
} else {
count[arr[i]] = 1
}
}
return count
}


Expand Down
8 changes: 7 additions & 1 deletion problems/getCountriesSortedByPopulation.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,13 @@
*
*/

function getCountriesSortedByPopulation() {
function getCountriesSortedByPopulation(arr) {
return arr.sort((country1, country2) => {
return country2.population - country1.population
}).map((object) => {
return object.country
})


}

Expand Down
7 changes: 5 additions & 2 deletions problems/isOdd.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@
* ex: isOdd(75); // true
*/

function isOdd() {

function isOdd(n) {
if (n % 2 !== 0){
return true
} else
return false
}

module.exports = isOdd
5 changes: 3 additions & 2 deletions problems/numberOfDigits.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@

*/

function numberOfDigits() {

function numberOfDigits(n) {
let totalDigits = n + ""
return totalDigits.length
}

module.exports = numberOfDigits
3 changes: 2 additions & 1 deletion problems/removeEvenStrings.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
* returns: []
*/

function removeEvenStrings() {
function removeEvenStrings(arr) {
return arr.filter((elem) => {return elem.length % 2 === 1})

}

Expand Down
9 changes: 7 additions & 2 deletions problems/removeNumbersAtOddIndices.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,13 @@
* ex: removeNumbersAtOddIndices([5, 4, 3, 2, 1]);
* returns: [5, 3, 1]
*/
function removeNumbersAtOddIndices() {

function removeNumbersAtOddIndices(arr) {
let newArray = []
for (let i = 0; i < arr.length; i++)
if (i % 2 === 0){
newArray.push(arr[i])
}
return newArray
}

module.exports = removeNumbersAtOddIndices
4 changes: 3 additions & 1 deletion problems/removeOddNumbers.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
* ex: removeOddNumbers([2, 4, 6])
* returns: [2, 4, 6]
*/
function removeOddNumbers() {
function removeOddNumbers(arr) {
let noOddnumbers = arr.filter((elem) => { return elem % 2 === 0});
return noOddnumbers

}

Expand Down
10 changes: 9 additions & 1 deletion problems/removeVowels.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,15 @@
*
*/

function removeVowels() {
function removeVowels(str) {
let newStr = ""
let vowArr = ["a", "e", "i", "o", "u", "A", "E", "I", "O", "U"]
for (let i = 0; i <str.length; i++) {
if (!vowArr.includes(str[i])){
newStr += str[i]
}
}
return newStr

}

Expand Down
11 changes: 10 additions & 1 deletion problems/sevenBoom.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,16 @@
* 17 is also replaced with 'BOOM' because it contains a 7.
*/

function sevenBoom() {
function sevenBoom(n) {
let array = []
for (let i = 1; i <= n; i++){
if (i % 7 === 0 || (i + "").includes(7)){
array.push("BOOM")
} else {
array.push(i)
}
}
return array

}

Expand Down
8 changes: 7 additions & 1 deletion problems/smallest.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,13 @@
* returns 1 (does not matter if it is the first or second 1)
*/

function smallest() {
function smallest(arr) {
let small = arr[0]
for (let i = 0; i < arr.length; i++)
if (arr[i] < small){
small = arr[i]
}
return small

}

Expand Down