From 66a5a64fed70c03d8f054b586ce2948b0b8d7270 Mon Sep 17 00:00:00 2001 From: TKH Student 36 Date: Mon, 20 Sep 2021 22:11:20 -0400 Subject: [PATCH 1/3] String-Exercises Lab --- string.js | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/string.js b/string.js index 07d52da..bc0d698 100644 --- a/string.js +++ b/string.js @@ -6,6 +6,19 @@ // DrEvil(1000000): 1000000 dollars (pinky) // answer below: +function DrEvil(amount){ + if (parseInt(amount) === 10000000) { + return amount + "dollars" + "pinky" + } + else { + + return amount + "dollars" + } + + + + console.log(DrEvil) +} @@ -20,6 +33,13 @@ //mixUp('dog', 'dinner'): 'dig donner' //write answer below +function mixUP( str1, str2){ + let a = str1.slice(0,2) + let b = str2.slice(0,2) + return b + str1[2] + " " + a + str2[2] +} + +console.log(mixUP("mix", "pod")) @@ -31,6 +51,11 @@ //fixstart('babble'): 'ba**le' //write answer below +function fixStart(str) { + let i = str.slice(1) + return str[0] + i.replace(/b/g, '*'); + } + console.log(fixStart("babble")); From e47116b490e3f47ab2796d2c908f93e346b2771d Mon Sep 17 00:00:00 2001 From: TKH Student 36 Date: Mon, 20 Sep 2021 22:50:22 -0400 Subject: [PATCH 2/3] Lab Assignment --- string.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/string.js b/string.js index bc0d698..5aa7034 100644 --- a/string.js +++ b/string.js @@ -71,7 +71,18 @@ function fixStart(str) { //write answer below - +function verbing(word){ + if (word.length < 3) + return word; + if(word.slice((-3) == 'ing')){ + return word + 'ly'; + } else{ + return word + 'ing' + } +} +console.log(verbing('swim')) +console.log(verbing('swimming')) +console.log('go'); From 5963aed65a3f0a31d9d03ad25f0efe4cbf113e08 Mon Sep 17 00:00:00 2001 From: TKH Student 36 Date: Mon, 20 Sep 2021 22:55:03 -0400 Subject: [PATCH 3/3] fixed --- string.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/string.js b/string.js index 5aa7034..162999d 100644 --- a/string.js +++ b/string.js @@ -7,7 +7,7 @@ // answer below: function DrEvil(amount){ - if (parseInt(amount) === 10000000) { + if (parseInt(amount) === 1000000) { return amount + "dollars" + "pinky" } else { @@ -16,9 +16,11 @@ function DrEvil(amount){ } - - console.log(DrEvil) } + console.log(DrEvil(10)) + console.log(DrEvil(1000000)) + +