Skip to content

WEBEU2 - JavaScript-II - Isaac Aderogba 🇮🇪 - #1

Open
IsaacAderogba wants to merge 8 commits into
masterfrom
isaac-aderogba
Open

WEBEU2 - JavaScript-II - Isaac Aderogba 🇮🇪#1
IsaacAderogba wants to merge 8 commits into
masterfrom
isaac-aderogba

Conversation

@IsaacAderogba

Copy link
Copy Markdown
Owner

No description provided.

@maximesalomon maximesalomon left a comment

Copy link
Copy Markdown
Collaborator

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 => {

Copy link
Copy Markdown
Collaborator

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

// 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) {

Copy link
Copy Markdown
Collaborator

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"
});

Copy link
Copy Markdown
Collaborator

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");

Comment thread assignments/callbacks.js
}

last(items, function(lastItem) {
console.log("Q2 Callbacks: " + lastItem);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Read the question again

Copy link
Copy Markdown
Owner Author

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?

Comment thread assignments/callbacks.js

/* STRETCH PROBLEM */

function removeDuplicates(array, cb) {

Copy link
Copy Markdown
Collaborator

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!

Comment thread assignments/closure.js
// ==== Challenge 1: Write your own closure ====
// Write a simple closure of your own creation. Keep it simple!

function whoLikesIceCream(yourName) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🍦

Comment thread assignments/closure.js
// Return a function that when invoked increments and returns a counter variable.
let count = 0;
return function() {
return ++count;

Copy link
Copy Markdown
Collaborator

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++?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants