-
Notifications
You must be signed in to change notification settings - Fork 0
WEBEU2 - JavaScript-II - Isaac Aderogba 🇮🇪 #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good job on this Isaac 👍 Seems like you have a pretty good understanding of array methods, callbacks, and closures!
You had one exercise were you misread the question. Try to fix that when you have some time.
let fullName = []; | ||
const fullName = []; | ||
|
||
runners.forEach(element => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Try to use a more descriptive name than element when using array methods --> runner could be a good name here
console.log(fullName); | ||
|
||
// ==== Challenge 2: Use .map() ==== | ||
// The event director needs to have all the runner's first names converted to uppercase because the director BECAME DRUNK WITH POWER. Convert each first name into all caps and log the result | ||
let allCaps = []; | ||
// Explicit approach | ||
const allCaps = runners.map(function(element) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not use ES6 arrow function?
let largeShirts = []; | ||
const largeShirts = runners.filter(function(element) { | ||
return element.shirt_size === "L" | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ES6 array function are cleaner, start to use them:
--> const largeShirts = runners.filter(runner => runner.shirt_size === "L");
} | ||
|
||
last(items, function(lastItem) { | ||
console.log("Q2 Callbacks: " + lastItem); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Read the question again
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It says "last passes the last item of the array into the callback".
The code below passes the last item of the array into the callback:
return cb(**arr.length - 1**);
Where have I misunderstood that?
contains("Peanuts", items, function(booleanValue) { | ||
console.log("Q5.2 Callbacks: " + booleanValue); | ||
}); | ||
|
||
/* STRETCH PROBLEM */ | ||
|
||
function removeDuplicates(array, cb) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good job doing the stretch!
@@ -1,21 +1,55 @@ | |||
// ==== Challenge 1: Write your own closure ==== | |||
// Write a simple closure of your own creation. Keep it simple! | |||
|
|||
function whoLikesIceCream(yourName) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🍦
|
||
/* STRETCH PROBLEMS, Do not attempt until you have completed all previous tasks for today's project files */ | ||
|
||
|
||
// ==== Challenge 2: Create a counter function ==== | ||
const counter = () => { | ||
// Return a function that when invoked increments and returns a counter variable. | ||
let count = 0; | ||
return function() { | ||
return ++count; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the difference between ++count and count++?
No description provided.