From 45e9a569966aef631b914a3ad2b978097b9d18d3 Mon Sep 17 00:00:00 2001 From: J Sandate Date: Wed, 4 Oct 2017 15:38:29 -0700 Subject: [PATCH 1/3] complete sum function in accumulator problems set --- main.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/main.js b/main.js index 01b5d14..7584e2f 100644 --- a/main.js +++ b/main.js @@ -30,6 +30,13 @@ For example, the tests require that to complete this challenge, your function mu results on the index page in the browser. */ +function sum(arr) { + let result = arr.reduce((sum,value) => { + return sum + value; + }, 0); + return result; +} + From a3217cea92549b21c2f48f6a8e74288dcccf00c2 Mon Sep 17 00:00:00 2001 From: J Sandate Date: Wed, 4 Oct 2017 16:01:57 -0700 Subject: [PATCH 2/3] work on doubleLetters problem --- main.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/main.js b/main.js index 7584e2f..c374e2a 100644 --- a/main.js +++ b/main.js @@ -55,7 +55,14 @@ Write function named doubleLetters that will take a string and double every lett Example: if you pass it "abc" then it should return "aabbcc" */ - +function doubleLetters(str) { + let singled = str.split(''); + let doubled = singled.map(i => { + return singled + i; + }); + doubled.join(''); + return doubled; +} From 20e5549748aa64190b06165bc10da90e9473a88b Mon Sep 17 00:00:00 2001 From: J Sandate Date: Wed, 4 Oct 2017 16:35:13 -0700 Subject: [PATCH 3/3] complete doubleNumbers problem (passed) --- main.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/main.js b/main.js index c374e2a..eb6d52e 100644 --- a/main.js +++ b/main.js @@ -58,10 +58,9 @@ Example: if you pass it "abc" then it should return "aabbcc" function doubleLetters(str) { let singled = str.split(''); let doubled = singled.map(i => { - return singled + i; + return i + i; }); - doubled.join(''); - return doubled; + return doubled.join(''); } @@ -81,6 +80,12 @@ Write function named doubleNumbers that will take an array of numbers and return Example: if you pass it [1,2,3] then it should return [2,4,6] */ +function doubleNumbers(arr) { + let dn = arr.map(i => { + return i * 2; + }) + return dn; +}