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

Glasgow 6- Delnia Alipour-JavaScript/Core1- Week 3 - #223

Open
DelniaAlipour wants to merge 4 commits into
CodeYourFuture:mainfrom
DelniaAlipour:main
Open

Glasgow 6- Delnia Alipour-JavaScript/Core1- Week 3#223
DelniaAlipour wants to merge 4 commits into
CodeYourFuture:mainfrom
DelniaAlipour:main

Conversation

@DelniaAlipour

Copy link
Copy Markdown

No description provided.

@Dedekind561 Dedekind561 added reviewed A mentor has reviewed this code and removed reviewed A mentor has reviewed this code labels Mar 8, 2023

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

This is good work! I've made a comment about variable names at one point, but this is minor - the important thing was that you were able to iterate over arrays and come up with working answers. I'd encourage you to investigate the built-in array methods like .map() and .filter() - these will often help out in writing code that is simpler to write and simpler to understand.

Thanks also for the spelling corrections! I can use these and submit them back to the CYF repository 🥇

*/

// Example 1
// a does'nt have any value.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

a has the default value for a variable when no assignment has taken place, which is undefined.

// TODO
const containNumbers=[];
for(let i =0; i<allArticleTitles.length; i++){
let isContainNum= /[0-9]/.test(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.

Interesting use of a regular expression here!

Comment thread 2-mandatory/3-stocks.js
let change=0;
let average=0
for(let i =0; i<closingPricesForAllStocks.length; i++){
let j=closingPricesForAllStocks[i][closingPricesForAllStocks[i].length-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.

It's usually better to use full descriptions in variable names - variables like I, j and k can be used but usually as counters in loops (as has been used here with i) by convention. Try to think of a quite short but descriptive name to use - it should make the code that uses the variables easier to understand!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants