-
Notifications
You must be signed in to change notification settings - Fork 1
warm up done #236
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
warm up done #236
Conversation
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 job! I really like the way you implement. I left two small comments, but other than that LGTM!
function checkIfNumber(arg) { | ||
return !isNaN(parseFloat(arg)) && isFinite(arg); | ||
}; |
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.
Very nice function! 🔥
function getAVG(args) { | ||
const sum = args.reduce((acc, arg) => acc + parseFloat(arg), 0); | ||
return sum / args.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.
Nice! The casing of the name of the function is a bit odd though, it should be either getAvg
or getAverage
in my opinion.
|
||
|
||
|
||
console.log(main(args)); |
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.
What is the motivation for this console.log
? You already do all the printing in the main()
function itself, this line of code will either output an unncesessary undefined
or a duplicate value for average, which was already printed. You can remove this.
"main": "index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1", | ||
"start": "node avg.js" |
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.
As you did not need any npm
dependencies for your code, there is no need to make this code into an npm
package through npm init
. It would have been enough to just run your code via node avg.js
in the terminal.
Apologies for the delay.