jamsrahimi / hyf-javascript2 Goto Github PK
View Code? Open in Web Editor NEWHYF Javascript Module 2
HYF Javascript Module 2
Hi Jams, here is my feedback on your homework.
You've gone overboard a bit with this. I would have preferred a simple:
function foo(func) {
func();
}
That is what the assignment asked for and that is what should be delivered; no more no less. Remember, your next reviewer may be your potential employer.
Of course, you can experiment as much as you like but don't send it in as the answer to the assignment.
Your code works OK but again, I'm not interested to know whether the number is a prime or divisible by 2. The assignment doesn't ask for that. Similarly, I don't need reconfirmation that 15 is divisible by both 3 and 5. The preceding console.log statements already tell me that.
OK
OK
OK
No need to review my own version. Your version doesn't print the actual numbers, just the embedded arrays.
I didn't see you conclusion for the second case with the object.
OK
Your code works OK, but:
findDuplicateInArray
.arra1
is rather a cryptic nameor
let` in place of varYou are exploiting the fact that object keys are unique. You can do the same and cleaner with the newer ES6 Set()
. But if I refactor your code based on the bullets above it would become:
function findDuplicateInArray(array) {
const obj = {};
for (let i = 0; i < array.length; i++) {
obj[array[i]] = 0;
}
const result = [];
for (const key in obj) {
result.push(key);
}
return result;
}
const arr = ['a', 'b', 'c', 'd', 'a', 'e', 'f', 'c'];
console.log(findDuplicateInArray(arr));
Yeah! It looks very clear and understandable. And I can easily understand that you are able to find more than 1 solution for an issue. This is really good to improve yourself. The last thing which I can tell you that I learned lots of thing which I could not get during the class. Thanks a lot. ๐
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.