Skip to content
This repository was archived by the owner on Jan 14, 2024. It is now read-only.

Rahwa Ghebremichael London-8 JS-1 Week-3 - #21

Open
rahwafesseha wants to merge 1 commit into
CodeYourFuture:mainfrom
rahwafesseha:main
Open

Rahwa Ghebremichael London-8 JS-1 Week-3#21
rahwafesseha wants to merge 1 commit into
CodeYourFuture:mainfrom
rahwafesseha:main

Conversation

@rahwafesseha

Copy link
Copy Markdown

No description provided.

@rahwafesseha rahwafesseha changed the title Completed all the homework Rahwa Ghebremichael London-8 JS-1 Week-3 Jan 13, 2022

@DelroyGayle DelroyGayle left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Great work, Rahwa. Your hard work is an inspiration to me, and I am confident, it is to others.
Keep Going On!
Thank you.

// TODO
let arr = [];
let i = 0;
while (i % 2 === 0 && n > 0 && n > arr.length) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hello Rahwa
Regarding this function I believe you ought to have another look.
Your output should be one string with commas e.g. 0,2,4

See if you can redo this function with a 'string' in mind. You want to build a string from "" and add even numbers to this string until 'n' is reached.

let newClicks = [];

for (let i = 0; i < allArticleTitles.length; i++) {
for (let letter of allArticleTitles[i]) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hi Rahwa, as we are discovering there are many different ways of doing the same thing in JavaScript.
See if you a Google a solution whereby you can determine whether a character is a number using 'two' comparisons only!
In future, that method, will save you some typing!
:) :)

Comment thread 2-mandatory/4-stocks.js
sum += CLOSING_PRICES_LAST_5_DAYS_FOR_ALL_STOCKS[i][j];
}
newAverage.push(
(sum / CLOSING_PRICES_LAST_5_DAYS_FOR_ALL_STOCKS[i].length).toFixed(2) *

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

As an alternative multiply the number by 100, then Math.round() it; then divide by 100

That way, you don't have to convert a number to a string , then multiply by 1 to convert it to a number again

Comment thread 2-mandatory/4-stocks.js
// TODO
let newPriceChange = [];
for (let i = 0; i < closingPricesForAllStocks.length; i++) {
newPriceChange.push((closingPricesForAllStocks[i][4] - closingPricesForAllStocks[i][0]).toFixed(2) * 1);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

See my above comment regarding Math.round()

Comment thread 2-mandatory/4-stocks.js
// TODO
highestPrice =[];
for(let i=0; i < closingPricesForAllStocks.length; i++) {
let highestNum = closingPricesForAllStocks[i].sort(function(a,b){

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Nice!!

@mahsa2 mahsa2 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Nice job. It's great that you've spent time finishing your assignment, one day it comes to fruit 👍 💯 🥇

We finish the rest of the review on our next 1-1 session :)


}

return arr.toString(); // changes the numbers to strings

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

function evenNumbers(n) {
  let counter = 0;
  let evenNum = 0;
  while (counter < n) {
    console.log(evenNum);
    evenNum += 2
    counter++;
  }
}

The above prints every value on a different line. As an exercise let do this to print them as a comma separated string:

  1. Keep track of all the even numbers in the loop (hint: use array)
  2. After loop, console.log the array using the join: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/join

// TODO - Write for loop code here
for(i=0; i < WRITERS.length; i++) {
console.log(WRITERS[i] + " " + "is " + AGES[i] + " "+ "years old.");
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

  1. let i=0 ...
  2. " years old"
  3. `${WRITERS[i]} is ${AGES[i]} years old`


for(tubes of tubeStations) {
console.log(tubes);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

let tube ...

let result = str.toUpperCase();
for(letter of result) {
console.log(letter);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

let letter...


}
while(number <= 50)
return number;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggestion: put a newline after do {

@mahsa2 mahsa2 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pretty good job Rahwa 💯 🥇 👍
So happy to see you've worked on the extra questions too

}

return newString;
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cool solution ⭐

letter === "8"||
letter === "9") {
newClicks.push(allArticleTitles[i])
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I like that you've solved the problem correctly with the ways you knew 🥇

There is a function isNaN that can check if a string is not a number, which can help to do this step for you.

Comment thread 2-mandatory/4-stocks.js
// TODO
let newAverage =[]
let sum = 0;
for (let i = 0; i < CLOSING_PRICES_LAST_5_DAYS_FOR_ALL_STOCKS.length; i++) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

In the function, instead of using CLOSING_PRICES_LAST_5_DAYS_FOR_ALL_STOCKS, we need to use the parameter closingPricesForAllStocks, so that we can call the function for different arrays of prices.

Comment thread 3-extra/1-factorial.js
input= input*i;
console.log(input)
}
return input;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Nice one! ⭐

}

}
return bookTitles;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

👍 It's great that you've solved the problem by adding the highest rating manually. I am so happy you started looking into the extra exercises too.

For finding the highest rating with the code (so that you can use the function with other types of books array and rating that 4.8 is not their highest rating), primary a for loop over books before what you wrote, can find the max rating first, then you can replace it with the 4.8 in your above code. For that, you can use a variable with the max rating of 0 (minimum rating) and then if you find a book with more ratings than that, you update the maximum rating till you visit all the book ratings.

Comment thread 3-extra/3-fibonacci.js
}


return fib;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💯

@mahsa2 mahsa2 added the reviewed A mentor has reviewed this code label Jan 20, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

reviewed A mentor has reviewed this code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants