Skip to content

Commit

Permalink
all tests passed
Browse files Browse the repository at this point in the history
  • Loading branch information
Kristiina Kolu authored and Kristiina Kolu committed Feb 21, 2022
1 parent 88093f6 commit 8ce560a
Show file tree
Hide file tree
Showing 10 changed files with 8,382 additions and 167 deletions.
8,496 changes: 8,341 additions & 155 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/1-multiplication.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export const multiply = (a, b) => {
a * b
return a * b
}
10 changes: 9 additions & 1 deletion src/2-first-last.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
export const firstLast = (items) => {
return `First: ${items[0]}, Last: ${items[1]}`
if (!items.length){
return `No items!`
}
else if (items.length === 1){
return `Only item: ${items[0]}`
}
else{
return `First: ${items[0]}, Last: ${items[items.length-1]}`
}
}
2 changes: 1 addition & 1 deletion src/3-find-index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export const findIndex = (array, value) => {
return
return array.indexOf(value)
}
2 changes: 1 addition & 1 deletion src/4-angle-calculator.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export const angleCalculator = (turns) => {
return
return (turns * 360)
}
7 changes: 6 additions & 1 deletion src/5-month-name.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,10 @@ const months = [
]

export const monthName = (monthNumber) => {
return months[monthNumber]
if(monthNumber >= 1 && monthNumber <= 12){
return months[monthNumber-1]
}
else{
return null
}
}
2 changes: 1 addition & 1 deletion src/6-filter-numbers.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export const filterNumbers = (array, largerThan) => {
return array
return array.filter(item => item <= largerThan)
}
15 changes: 11 additions & 4 deletions src/7-is-empty.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
export const isEmpty = (stringArrayOrObject) => {
const type = typeof stringArrayOrObject

if (type === 'string') {
return stringArrayOrObject === ''
if (type === 'string' && stringArrayOrObject.length){
return false
}
else if (Object.prototype.toString.call(stringArrayOrObject) === '[object Array]' && stringArrayOrObject.length){
return false
}
else if (Object.prototype.toString.call(stringArrayOrObject) === '[object Object]' && Object.keys(stringArrayOrObject).length){
return false
}
else{
return true
}

return false
}
4 changes: 3 additions & 1 deletion src/8-hacker-speak.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
export const hackerSpeak = (words) => {
return words
return words.replaceAll("a", "4").replaceAll("e", "3", true).replaceAll("i", "1", true)
.replaceAll("o", "0", true).replaceAll("s", "5", true).replaceAll("A", "4").replaceAll("E", "3", true).replaceAll("I", "1", true)
.replaceAll("O", "0", true).replaceAll("S", "5", true)
}
9 changes: 8 additions & 1 deletion src/9-hashtags.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
export const hashtags = (text) => {
return text
let splitArray = text.split(" ")
let hastagsArray = []
for(let i = 0; i < splitArray.length; i++){
if (splitArray[i].charAt(0) === '#'){
hastagsArray.push(splitArray[i])
}
}
return(hastagsArray)
}

0 comments on commit 8ce560a

Please sign in to comment.