From 982f9ffd518cef381fac413832d89fbc08a2a8c9 Mon Sep 17 00:00:00 2001 From: nbal1618 <47106832+nbal1618@users.noreply.github.com> Date: Sat, 10 Aug 2019 14:47:15 +0100 Subject: [PATCH 1/5] Update hello function 10/8 Is that correct ? --- exercises/201-hello-world.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/exercises/201-hello-world.js b/exercises/201-hello-world.js index b84d923..e68611b 100644 --- a/exercises/201-hello-world.js +++ b/exercises/201-hello-world.js @@ -9,3 +9,7 @@ // Write a function "helloDefault" such that if no name is given it will return // 'Hello, world!' // Otherwise it behaves the same as the "hello" function. + +function hello (name) { + alert ("Hello, " + name); +} From ec9f653aead243f82111d6fcd1f393555e2db3d1 Mon Sep 17 00:00:00 2001 From: nbal1618 <47106832+nbal1618@users.noreply.github.com> Date: Tue, 13 Aug 2019 09:25:06 +0100 Subject: [PATCH 2/5] Update i would like a feedback, please. --- exercises/205-tip-calculator.js | 43 +++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/exercises/205-tip-calculator.js b/exercises/205-tip-calculator.js index 24c4f99..f88da10 100644 --- a/exercises/205-tip-calculator.js +++ b/exercises/205-tip-calculator.js @@ -10,6 +10,20 @@ // tipAmount(100, 'good') --> 20 // tipAmount(40, 'fair') --> 6 +var tipAmount = function(bill,service) { + var tip; + if (service = "good") { + tip *=bill*0.2; + } + else if (service = "fair") { + tip *=bill*0.15; + } + else { + tip *=bill*0.1; + } +} + + // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -21,6 +35,20 @@ // totalAmount(100, 'good') --> 120 // totalAmount(40, 'fair') --> 46 +var totalAmount = function(bill,service) { + var total; + if (service = "good") { + total = bill + tipAmount(bill,service); + } + else if (service = "fair") { + total = bill + tipAmount(bill,service); + } + else { + total = bill + tipAmount(bill,service); + } +} + + // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -31,3 +59,18 @@ // Examples: // splitAmount(100, 'good', 5) --> 24 // splitAmount(40, 'fair', 2) --> 23 + + +var splitAmount = function(bill,service,people) { + var split; + if (service="good") { + split = (bill + tipAmount(bill,service))/people; + } + else if(service="fair") { + split = (bill + tipAmount(bill,service))/people; + } + else { + split = (bill + tipAmount(bill,service))/people; + } +} + From ac3d7d9699619411a3b1b7e38a5e411f06bee347 Mon Sep 17 00:00:00 2001 From: nbal1618 <47106832+nbal1618@users.noreply.github.com> Date: Sat, 17 Aug 2019 09:26:35 +0100 Subject: [PATCH 3/5] Update I found a JSON format but I'm not sure how I can use it. Any suggestion is welcome! Also if you could let me know if the other functions are correct. --- exercises/208-predicate-functions.js | 37 ++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/exercises/208-predicate-functions.js b/exercises/208-predicate-functions.js index ac33924..f6c992d 100644 --- a/exercises/208-predicate-functions.js +++ b/exercises/208-predicate-functions.js @@ -21,6 +21,14 @@ // isVowel(99) --> false // isVowel({e: 'Elephant'}) --> false +var isVowel = function(char) { + if (char === 'a' || char === 'e' ) || char === 'i' || char === 'o' ) || char === 'u' ) { + return true; + } + else { + return false; + } + // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -36,7 +44,24 @@ // isOdd(5) --> true // isOdd('7') --> false // isOdd(3.14) --> false + + var isEven = function(num) { + if (num%2 == 0) { + return true; + } + else { + return false; + } + } + var isOdd = function(num) { + if (num%2 == 1) { + return true; + } + else { + return false; + } + } // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -53,3 +78,15 @@ // isCapitalCity('Texas', 'Houston') --> false // isCapitalCity('Alaska', 'Juneau') --> true // isCapitalCity('Strawberry', 'Mango') --> false + + + + + + + + + + + + From 639b56af9a1ad8962668e712a2dcbfcc4b9d2702 Mon Sep 17 00:00:00 2001 From: nbal1618 <47106832+nbal1618@users.noreply.github.com> Date: Mon, 19 Aug 2019 06:45:55 +0100 Subject: [PATCH 4/5] Update --- exercises/210-fizzbuzz.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/exercises/210-fizzbuzz.js b/exercises/210-fizzbuzz.js index 2ddfeba..2623056 100644 --- a/exercises/210-fizzbuzz.js +++ b/exercises/210-fizzbuzz.js @@ -9,3 +9,19 @@ // Examples: // fizzbuzz(3) --> '..fizz' // fizzbuzz(15) --> '..fizz.buzzfizz..fizzbuzz.fizz..fizzbuzz' + +var fizzbuzz = function(n) { + var str = []; + if (n%3 == 0 && n&5 == 0) { + return str = str + "fizzbuzz"; + } + else if (n%3 == 0 && n%5 != 0) { + return str = str + "fizz"; + } + else if (n%3 != 0 && n%5 == 0) { + return str = str + "buzz"; + } + else { + return str = str + "."; + } + From d4cd93321b7cd1e04837c35e6d392b3759cf65f8 Mon Sep 17 00:00:00 2001 From: nbal1618 <47106832+nbal1618@users.noreply.github.com> Date: Mon, 19 Aug 2019 07:22:18 +0100 Subject: [PATCH 5/5] Update It must be a more concise version of this... Please leave a comment. --- exercises/211-rock-paper-scissors.js | 29 ++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/exercises/211-rock-paper-scissors.js b/exercises/211-rock-paper-scissors.js index e3250fa..cfdac25 100644 --- a/exercises/211-rock-paper-scissors.js +++ b/exercises/211-rock-paper-scissors.js @@ -6,3 +6,32 @@ // rockPaperScissors('rock', 'scissors') --> 'player 1' // rockPaperScissors('rock', 'paper') --> 'player 2' // rockPaperScissors('paper', 'paper') --> 'draw' + +var rockPaperScissors = function(throw1,throw2) { + + if (throw1 == throw2) { + return = 'draw'; + } + else if (throw1 == 'rock' && throw2 == 'scissors') { + return = 'player1'; + } + else if (throw1 == 'rock' && throw2 == 'paper') { + return = 'player2'; + } + else if (throw1 == 'scissors' && throw2 == 'paper') { + return = 'player1'; + } + else if (throw1 == 'scissors' && throw2 == 'rock') { + return = 'player2'; + } + else if (throw1 == 'paper' && throw2 == 'scissors') { + return = 'player2'; + } + else if (throw1 == 'paper' && throw2 == 'rock') { + return = 'player1'; + } + + + + +