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
8 changes: 4 additions & 4 deletions src/dates/index.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
// import moment here; use this package in each function

var moment = require('moment')
const today = () => {
// write code for dates.today

return moment().format('dddd')
}

const calendar = () => {
// write code for dates.calendar

return moment().format('MMM DD, YYYY')
}

const currentTime = () => {
// write code for dates.currentTime

return moment().format('hh:mm:ss A')
}

module.exports = {
Expand Down
19 changes: 15 additions & 4 deletions src/numbers/index.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,27 @@
const isEven = (num) => {
// write code for numbers.isEven

if (num%2 == 0)
return true;
else
return false
}

const sum = (arr) => {
// write code for numbers.sum

}
return arr.reduce((accumulator, currentValue) => accumulator + currentValue);
};

const comboSum = (arr, sum) => {
// write code for numbers.comboSum

for (let i = 0; i != arr.length; i++) {
for (let j = 0; j != arr.length; j++) {
if (arr[i] + arr[j] === sum) {
return true
} else {
return false
}
}
}
}

module.exports = {
Expand Down
9 changes: 8 additions & 1 deletion src/strings/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,18 @@ const split = (str, delim) => {

const pairs = (str) => {
// write code for strings.pairs

let newArray = []
for (let i = 0; i < str.length; i+=2) {
temp = (str[i] + str[i+1])
newArray.push(temp.split("").join(""))
}
// newArray.push(str.split("").join(" , "))
return newArray
}

const reverse = (str) => {
// write code for strings.reverse
return str.split("").reverse().join("");

}

Expand Down