Skip to content
This repository was archived by the owner on Oct 26, 2020. It is now read-only.

week 2 done#936

Open
HarrisSheraz20 wants to merge 1 commit intoCodeYourFuture:masterfrom
HarrisSheraz20:js1-week2
Open

week 2 done#936
HarrisSheraz20 wants to merge 1 commit intoCodeYourFuture:masterfrom
HarrisSheraz20:js1-week2

Conversation

@HarrisSheraz20
Copy link
Copy Markdown

Your Details

Your Name: Harris Sheraz
Your City: London
Your Slack Name: Harris Sheraz

Homework Details

Module: JavaScript-1
Week: 2

Copy link
Copy Markdown
Member

@illicitonion illicitonion left a comment

Choose a reason for hiding this comment

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

Well done, this is a really good effort :) I left a few comments with some things to fix up, but this is some really good progress!

let isHappy = true;

if (isHappy) {
if (!isHappy) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

While this change makes the test pass, reading the code, it doesn't really make much sense. If isHappy is true, we'll return I am not happy which doesn't sound right...

I realise this is a weird and very contrived exercise, but is there another change you could make which would mean that this function made a bit more sense?


function remove(arr, index) {
return; // complete this statement
arr.splice(index, 1);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This works except that one of the requirements of this function is that it doesn't change the original array - splice changes the original array. Can you give this another go making sure not to change the original array?


let newArr = [];
for (let i = 0; i < arr.length; i++) {
arr[i] = arr[i];
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What does this line do?

function formatPercentage(arr) {

let newArr = [];
for (let i = 0; i < arr.length; i++) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This function returns the right thing, but it will change the values in the input array too - can you change the function so that it won't change the input array?

return arr;
}

function sortAges(arr) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Very impressive! Well done!

console.log(e); 9, 13
4. How many times is "f1" called? // 1st call of f1 is when consol.log(e) = 9, // last time f1 is called and resulting in console.log(e) = 13
5. How many times is "f2" called? // 1st call of f2 is when console.log(d) = 4, second time f2 is called and resulting in console.log(d) = 6 // last time f2 is called and resulting in console.log(d) = 8
6. What value does the "a" parameter take in the first "f1" call? // value 8
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is actually the answer to question 7 :) This is asking what value the a parameter on line 21 will have, not what the a variable on line 19 will have. Can you try this one again?

@illicitonion illicitonion self-assigned this Jun 10, 2020
@illicitonion illicitonion added the reviewed A mentor has reviewed this PR label Jun 12, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

reviewed A mentor has reviewed this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants