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

Ezgi-Gunes-JavaScript-Core-1-Coursework-Week3-London8 - #27

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

Ezgi-Gunes-JavaScript-Core-1-Coursework-Week3-London8#27
Ezgi3406 wants to merge 1 commit into
CodeYourFuture:mainfrom
Ezgi3406:main

Conversation

@Ezgi3406

Copy link
Copy Markdown

No description provided.

@hachi-ops hachi-ops 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.

Hi Ezgi, I reviewed your 'exercises' folder. Hope you'll find it helpful:)

even.push(i);
i+=2;

}return even;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The final output is correct except it should return a string. Think of a method that allows you to do that.

function findFirstJulyBDay(birthdays) {
// TODO
}
const findFirstJulyBDay = BIRTHDAYS.find(e=>e.includes('July'));

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The console displays an error message saying it is not a function. There might be some syntax problems here.

startNumber++;
} while (startNumber < n);
return sum;
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Your code would work if you placed your changes inside the function.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The code does work :) Maybe it looked confusing on a github diff?

let i = 0;
while(i < 26) {

for(let i = 0; i < 26; 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.

Good:)

// TODO - Write for loop code here
for (var 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.

Good use of template literals.

];
for(let element of tubeStations){

console.log(element);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Good but get rid of the unnecessary spaces:)

// TODO Use a for-of loop to capitalise and output each letter in the string seperately.
let str = "codeyourfuture";
for(let element of str){
const myArr=str.toUpperCase().split('');

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 think you should target 'element' here not 'str'. The aim of this exercise is to output each letter separately, not the whole string. Also, I don't think you need split method here because it unnecessarily converts you string back to an array.

@jstadnik jstadnik 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.

Congratulations on completing all the exercises!

You pulled a little ahead of the class -- these exercises were about loops, while you used a number of array methods and anonymous functions. It's not incorrect, but you may want to be mindful about making sure you do know how to use for/while loops when you need to.

You should be mindful of two "presentation" issues:

  1. indentation -- in a number of places you indented things inconsistently/wrongly. I haven't pointed them all out, but I can, if that's helpful. Are you using any auto-formatter in your IDE, such as prettier?
  2. leftover debug code -- make sure you remove print (console.log) statements you used for debugging before you submit your PR.

On the whole, though, I am very impressed! Great job! 🙂

evenNumbers(0); // should output nothing
evenNumbers(10); // should output 0,2,4,6,8,10,12,14,16,18

console.log(evenNumbers(3)); // should output 0,2,4

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

So, technically, according to the instructions, the function should console.log things.

let even=[]
let i =0

while(even.length<n){

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 findFirstJulyBDay(birthdays) {
// TODO
}
const findFirstJulyBDay = BIRTHDAYS.find(e=>e.includes('July'));

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

While this is a clever solution and kind of does solve the problem, you should try and implement things as asked by the exercise, rather than modify the check. So, here for example, you could do

function findFirstJulyBDay(birthdays) {
    return birthdays.find(e=>e.includes('July'));
}

To create a function.

Also, this should technically be a "while" loop exercise -- how would you complete it with a while loop?

startNumber++;
} while (startNumber < n);
return sum;
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The code does work :) Maybe it looked confusing on a github diff?

let startNumber = 0;
let sum = 0;
do {
sum += startNumber * 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.

Nice :)

let totalCharacterNumber = 0;
for (let i = 0; i < allArticleTitles.length; i++) {
totalCharacterNumber =
totalCharacterNumber + allArticleTitles[i].split("").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.

.length works on strings, too:

> str = "somestr"
'somestr'
> str.length
7

Comment thread 2-mandatory/4-stocks.js
}
average = parseFloat((sum/counter).toFixed(2))

console.log(average);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

You should try and remove all console.log you used for debugging before your final submission.

Comment thread 2-mandatory/4-stocks.js

for(let price of closingPricesForAllStocks){

let priceDiff=Number(price[price.length-1]-price[0])

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Is Number needed here?

// TODO
let bookTitles=[];
for(let i=0; i<books.length; i++){
if(books[i].rating > 4.8){

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This works for the exact test case provided, but wouldn't work with different inputs (for instance, if a genre's highest-rated book was rated 4.5), or there were two books rated > 4.8 in one genre.

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

let fibonacci = [0, 1];
for(i = 2; i < n; 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.

Great work on this one!

@jstadnik jstadnik added the reviewed A mentor has reviewed this code label Jan 16, 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