Flatiron SE Day 1 pt 2
Time to break into the second lab function lab. I have my extra large coffee so lets get into it!
This lab is all about hoisting, anonymous functions, scope, closure, and immediately-invoked function expressions.
Here is how I solved it:
/*this sets an activity for Saturday as the default if no other argument is passed in */
function saturdayFun(activity = "roller-skate"){
return This Saturday, I want to ${activity}!
}
/*function expression for Monday with a Default that can be overridden */
let mondayWork = function(activity="go to the office"){
return This Monday, I will ${activity}.
}
/* create a function expression wrapAdjective
when initialized with '' creates a function that, when called, wraps an adjective in a highlight
when initialized with '||' creates a function that, when called, wraps an adjective in a highlight:
*/
let wrapAdjective = function(style = ""){
return function(adjective="neat") {
return You are ${style}${adjective}${style}!
}
}
I'm going to need to spend more time studying this one. The Wrap adjective function took lots of google searches and I still do not feel confident in being able to replicate this in any real world setting.
Top comments (0)