-
-
Notifications
You must be signed in to change notification settings - Fork 283
London 10 | Shahid Amin | JavaScript-Core-1-Coursework-Week3 #277
base: main
Are you sure you want to change the base?
Conversation
Comment to show the stages of working - This needs to be put in a function
@@ -21,7 +21,7 @@ function sayHello() { | |||
|
|||
let hello = sayHello(); | |||
console.log(hello); | |||
|
|||
//There is no value passed to the function sayHello |
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, but not every function will have parameters. There's something missing inside the function sayHello
for it not to be undefined. Can you spot what it is?
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.
A little hint
let numbers = []; // add numbers from 1 to 10 into this array | ||
let mentors; // Create an array with the names of the mentors: Daniel, Irina and Rares | ||
let numbers = [1,2,3,4,5,6,7,8,9,10]; // add numbers from 1 to 10 into this array | ||
let mentors = ["Daniel", "Irina", "Rares"]; // Create an array with the names of the mentors: Daniel, Irina and Rares | ||
|
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.
Nice.
} | ||
|
||
function last(arr) { | ||
return; // complete this statement | ||
return arr[arr.length - 1]; ; // complete this statement |
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.
👍
AGES.forEach(k => { | ||
WRITERS.forEach(i => { | ||
console.log(i + " is " + k + " years old") | ||
}) | ||
}) |
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.
This doesn't look correct. Currently, it will say that every writer is 59,40,41,63 and 49 years old.
// TODO | ||
for (let dateOfBirth of BIRTHDAYS) { | ||
let getMonth = dateOfBirth.split(' ')[0]; | ||
if (getMonth === "July") { | ||
return dateOfBirth; | ||
} | ||
} |
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.
@@ -5,7 +5,12 @@ | |||
Implement the function below, which will return a new array containing only article titles which will fit. | |||
*/ | |||
function potentialHeadlines(allArticleTitles) { | |||
// TODO | |||
const shortArticleTitles = []; | |||
for (let articleTitle of allArticleTitles) { |
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.
indentation seem off here too.
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 overall code inside the function will work correct but it doesn't seem to output a value. You are definitely missing something here.
@@ -14,7 +19,16 @@ function potentialHeadlines(allArticleTitles) { | |||
(you can assume words will always be seperated by a space) | |||
*/ | |||
function titleWithFewestWords(allArticleTitles) { | |||
// TODO | |||
let fewestword = allArticleTitles[0].split(' ').length; |
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.
Well done.
@@ -8,6 +8,8 @@ | |||
|
|||
let numbers = [1, 2, 3]; // Don't change this array literal declaration | |||
|
|||
numbers[3] = numbers.push(4) | |||
//The first value is 1??? |
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 spot I'll forward that observation. But if it wasn't a 1
how would you change its value?
let arrayOfLengths = allArticleTitles.map(w => w.length); | ||
console.log(arrayOfLengths) | ||
let sumOfLengths = 0; | ||
for (let i = 0; i < arrayOfLengths.length; i++) { | ||
sumOfLengths += arrayOfLengths[i]; | ||
console.log(sumOfLengths) | ||
} | ||
|
||
let sumOfArrayLengths = arrayOfLengths.length | ||
console.log(sumOfArrayLengths) | ||
|
||
let result = sumOfLengths/sumOfArrayLengths; | ||
console.log(result) |
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.
Indentation is off here too.
averageprice.push(Math.round(average * 100) / 100); | ||
|
||
} | ||
return averageprice; |
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 effort. Please make sure you indent your code correctly.
Functions for the radio station and the books completed.
No description provided.