From fecb8ec2210ac4609ca9685268cc2ce688664f34 Mon Sep 17 00:00:00 2001 From: BrandonPerry-co Date: Mon, 22 Mar 2021 22:58:31 -0800 Subject: [PATCH] Pushed changes --- src/dates/index.js | 8 ++++---- src/numbers/index.js | 19 +++++++++++++++---- src/strings/index.js | 9 ++++++++- 3 files changed, 27 insertions(+), 9 deletions(-) diff --git a/src/dates/index.js b/src/dates/index.js index 91cdc8e..7f733b4 100644 --- a/src/dates/index.js +++ b/src/dates/index.js @@ -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 = { diff --git a/src/numbers/index.js b/src/numbers/index.js index 014b8ca..0d14edc 100644 --- a/src/numbers/index.js +++ b/src/numbers/index.js @@ -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 = { diff --git a/src/strings/index.js b/src/strings/index.js index eee93b9..2d91b5c 100644 --- a/src/strings/index.js +++ b/src/strings/index.js @@ -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(""); }