ozgurleo / hyf-javascript1 Goto Github PK
View Code? Open in Web Editor NEWHomework for JavaScript 1
Homework for JavaScript 1
Hi Ozgur, here is my feedback on your homework for week 3.
I'm disappointed that you didn't follow up on my feedback for week 2:
1. You should include a
.eslintrc
file in the root folder of your repo. Please check again section 5.1 Preparation of the assignment and make the necessary changes.
6. Your code in general is not formatted in a standard way. That indicates to me that you didn't set the VSCode settings correctly. We did this in class last Sunday, but somehow you missed it. Please check again the VSCode Tips for these settings.
You are missing an 'use strict';
line.
If I call your function twice like this:
console.log(sum(12, 25, 97));
console.log(sum(12, 25, 97));
then I get this error:
console.log(sum(12, 25, 97));
^
TypeError: sum is not a function
In this line you are actually reassigning the name sum
from what it was (a function) to a number:
return sum = (a + b + c);
A correct version of the code would look like this:
'use strict';
function sum(a, b, c) {
return a + b + c;
}
console.log(sum(12, 25, 97));
You have made an error in the 'use strict';
line:
'use strict ;'
The semicolon should be outside of the quotation marks.
You have made the same error as in 1. I can't call your function twice without getting an error.
Missing 'use strict'
.
The output does not meet the requirements of the assignment. For your object I would have expected the output:
location = France
duration = 2 weeks
price = 1000
You are not using the parameter object
of your function. Instead you are accessing the external variable vocationPakkage1
directly. By the way, this variable contains spelling errors flagged by the VSCode spell checker. You should not leave those errors uncorrected.
Missing 'use strict'
.
You seem to have missed this part of the instructions:
Your function should return a string, ...
Therefore, your function should not include a console.log
. Instead, it should be a pure function, returning a string that you can then console.log when you call it.
I'm missing the word 'a', as in 'a red car'.
Correct!
Missing 'use strict'
.
Your function should return a string.
If I call your function like this, i.e. with an age of 0.5:
vehicleType('blue', 2, 0.5);
I get as output:
blue motorbike used
But I expected this 0.5 year old motorbike to be new. For correct English you must swap the order of the words 'motorbike' and 'used'. And you need to add the word 'a': a blue new motorbike
.
The code works correctly, but the code formatting is incorrect.
The name years
does not seem a match for the values 'used'
and 'new'
. The word condition
seems a better choice.
You have used many things here that we didn't teach in class. In principle, that is fine, if it is not copy & paste work from the Internet and you can explain what the code does.
You should place the variable pluralVehicles
inside the function body to make the function pure.
Your output can be improved:
ozgur's garage helps your cars, motorbikes, bikes and caravans maintenance and repair.
^Names starts with a capital ^unwanted extra space
Assignments 9-13 are missing.
Hi Ozgur,
I was assigned to review your homework this week,
Everything is working great, just couple of things..
const
to declare x
, if you declare a variable with const you can't reassign a new value to it later on, so using let
would be better here, my suggestion is:"use strict";
let x; // defining the variable without initializing it
console.log("the value of my variable x will be : undefined"); // same as you did
console.log(x);
x = 258; // initializing x with 258
console.log("the value of my variable x will be : 258"); //
console.log(x);
In step4 you're missing two semicolons ;).
In step6 stars =
isn't the proper way to declare an empty array, please see this Quora.
also we're supposed to push Daan's favorite animal (baby pig) to the array favoriteAnimals
using something like favoriteAnimals.push("baby pig");
See you in class.
Hi Ozgur, here is my feedback on your homework for week 2.
1. You should include a .eslintrc
file in the root folder of your repo. Please check again section 5.1 Preparation of the assignment and make the necessary changes.
2. Be consistent in your use of quotes as string delimiter. Either choose single quotes or double quotes and then stick to that for all of your code (I prefer single quotes myself).
3. Do not use the var
keyword. Use const
and let
instead.
4. In 2-arrays.js
you have declared the variable removed
twice. Because you used the var
keyword, JavaScript did not warn you about this error. Had you used const
or let
you would have received a runtime error, and you would have been prompted to correct the situation.
5. You should not use parentheses around a string constant, as you have in lines 6 and 15 of 2-arrays.js
. They are not needed and can therefore lead to confusion (especially for other people looking at your code).
6. Your code in general is not formatted in a standard way. That indicates to me that you didn't set the VSCode settings correctly. We did this in class last Sunday, but somehow you missed it. Please check again the VSCode Tips for these settings.
7. Make sure you act on spelling errors flagged by VSCode. capricorb
-> capricorn
8. You did not add Mauro's favorite animal: 'turtle' in 2-arrays.js
.
9. In line 15 of 2-arrays.js
, where you are looking for the index of meerkat
, it would be better to save that index into a variable. The reason for that is because you are trying delete meerkat
from the array in line 16. You should not "hard code" the number 1, but instead use the value you found earlier. Then you can easily deal with the situation of the index of meerkat
being changed, e.g. because something was inserted, or that meerkat
was deleted by some other code. In the latter case the index would be -1, indicating that nothing was found.
Example:
const meerkatIndex = favoriteAnimals.indexOf('meerkat');
console.log('Item to be deleted is at index: ' + meerkatIndex);
if (meerkatIndex !== -1) {
favoriteAnimals.splice(meerkatIndex, 1);
}
console.log(favoriteAnimals);
10. You have saved the result from .splice()
in a variable removed
. However there is no need for these variables as you are not using them elsewhere. You should only introduce variables if they are needed somewhere else.
11. As Mansour mentioned, the variable daysinAyear
is not accurate camelCase. Each word, except the first one should start with a capital: daysInAYear
.
12. Do not use ==
(line 27 of 3-months.js
). Use strict equality instead: ===
.
13. Your file 4-maartje.js
is not well-formatted. The amount printed should have two decimal digits and use the โฌ
sign. If I change Maartjes hourly rate from 30 to 29 I get this output: Maartje has earned 541.3333333333334 EUR. How can we pay out this amount up to the last decimal?
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.