From 8f82d723b791977c2360cd4f13aebb29fa9669b7 Mon Sep 17 00:00:00 2001 From: Jen Kelly Date: Tue, 6 May 2025 16:34:14 -0400 Subject: [PATCH 1/7] Pass tests 1-3 for saturdayFun --- index.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/index.js b/index.js index c44a93222..beeb76d00 100644 --- a/index.js +++ b/index.js @@ -1 +1,9 @@ // code your solution here +function saturdayFun(activity) { + switch (activity) { + case "bathe my dog": + return "This Saturday, I want to bathe my dog!"; + default: + return "This Saturday, I want to roller-skate!"; + } +} From f3541c267df746f75d2cbd286a7d758e62dd788f Mon Sep 17 00:00:00 2001 From: Jen Kelly Date: Tue, 6 May 2025 16:39:38 -0400 Subject: [PATCH 2/7] Pass tests 1-3 for mondayWork --- index.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/index.js b/index.js index beeb76d00..7db6cb829 100644 --- a/index.js +++ b/index.js @@ -7,3 +7,12 @@ function saturdayFun(activity) { return "This Saturday, I want to roller-skate!"; } } + +function mondayWork(activity) { + switch (activity) { + case "work from home": + return "This Monday, I will work from home."; + default: + return "This Monday, I will go to the office."; + } +} From b8759515413b42a6757de1d51a35086eae61e471 Mon Sep 17 00:00:00 2001 From: Jen Kelly Date: Tue, 6 May 2025 17:01:55 -0400 Subject: [PATCH 3/7] Re-do saturdayFun with template literals and default argument --- index.js | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index 7db6cb829..ac5412da6 100644 --- a/index.js +++ b/index.js @@ -1,11 +1,20 @@ // code your solution here -function saturdayFun(activity) { +// function saturdayFun(activity) { +// switch (activity) { +// case "bathe my dog": +// return "This Saturday, I want to bathe my dog!"; +// default: +// return "This Saturday, I want to roller-skate!"; +// } +// } + +function saturdayFun(activity = "roller-skate") { switch (activity) { case "bathe my dog": - return "This Saturday, I want to bathe my dog!"; - default: - return "This Saturday, I want to roller-skate!"; + activity = "bathe my dog"; } + + return `This Saturday, I want to ${activity}!`; } function mondayWork(activity) { @@ -16,3 +25,5 @@ function mondayWork(activity) { return "This Monday, I will go to the office."; } } + +function wrapAdjective() {} From 5811527fe974741b0791cbdc9211997e39c6d115 Mon Sep 17 00:00:00 2001 From: Jen Kelly Date: Tue, 6 May 2025 17:06:47 -0400 Subject: [PATCH 4/7] Re-do mondayWork with template literals and default argument --- index.js | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/index.js b/index.js index ac5412da6..0a8c2535a 100644 --- a/index.js +++ b/index.js @@ -1,13 +1,3 @@ -// code your solution here -// function saturdayFun(activity) { -// switch (activity) { -// case "bathe my dog": -// return "This Saturday, I want to bathe my dog!"; -// default: -// return "This Saturday, I want to roller-skate!"; -// } -// } - function saturdayFun(activity = "roller-skate") { switch (activity) { case "bathe my dog": @@ -17,13 +7,13 @@ function saturdayFun(activity = "roller-skate") { return `This Saturday, I want to ${activity}!`; } -function mondayWork(activity) { +function mondayWork(activity = "go to the office") { switch (activity) { case "work from home": - return "This Monday, I will work from home."; - default: - return "This Monday, I will go to the office."; + activity = "work from home"; } + + return `This Monday, I will ${activity}.`; } function wrapAdjective() {} From 54ddfba522be28ac1cad2577c16f8dbab047133f Mon Sep 17 00:00:00 2001 From: Jen Kelly Date: Wed, 7 May 2025 11:19:33 -0400 Subject: [PATCH 5/7] Refactor mondayWork as a function expression --- index.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/index.js b/index.js index 0a8c2535a..db0d908f4 100644 --- a/index.js +++ b/index.js @@ -1,19 +1,23 @@ +// use function here function saturdayFun(activity = "roller-skate") { switch (activity) { case "bathe my dog": activity = "bathe my dog"; } - return `This Saturday, I want to ${activity}!`; } -function mondayWork(activity = "go to the office") { +const mondayWork = function (activity = "go to the office") { switch (activity) { case "work from home": activity = "work from home"; } - return `This Monday, I will ${activity}.`; -} +}; +mondayWork(); -function wrapAdjective() {} +// +function wrapAdjective() { + let result = wrapAdjective("*"); + let emphatic = result("a hard worker"); +} From 8a934fff9666ef28c0124af1cc802634ad1cd616 Mon Sep 17 00:00:00 2001 From: Jen Kelly Date: Wed, 7 May 2025 15:08:48 -0400 Subject: [PATCH 6/7] Create code for wrapAdjective that works but doesn't pass tests --- index.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index db0d908f4..d12735568 100644 --- a/index.js +++ b/index.js @@ -16,8 +16,7 @@ const mondayWork = function (activity = "go to the office") { }; mondayWork(); -// -function wrapAdjective() { - let result = wrapAdjective("*"); - let emphatic = result("a hard worker"); +function wrapAdjective(result = "*", emphatic = "a dedicated programmer") { + return `You are ${result}${emphatic}${result}!`; } +wrapAdjective(); From 1e13c183729d13d5bc8a004af165d3c39e05303e Mon Sep 17 00:00:00 2001 From: Jen Kelly Date: Wed, 7 May 2025 15:38:06 -0400 Subject: [PATCH 7/7] Refactor wrapAdjective as scope chain --- index.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index d12735568..06f2cd4b9 100644 --- a/index.js +++ b/index.js @@ -1,4 +1,3 @@ -// use function here function saturdayFun(activity = "roller-skate") { switch (activity) { case "bathe my dog": @@ -16,7 +15,11 @@ const mondayWork = function (activity = "go to the office") { }; mondayWork(); -function wrapAdjective(result = "*", emphatic = "a dedicated programmer") { - return `You are ${result}${emphatic}${result}!`; +function wrapAdjective(string = "*") { + const innerFunction = function (adjective = "special") { + return `You are ${string}${adjective}${string}!`; + }; + return innerFunction; } -wrapAdjective(); + +wrapAdjective()();