hyf-javascript1's People
Forkers
talalalamdar-2hyf-javascript1's Issues
Feedback DOM manipulation
Hi Talal,
Your web page looks nice. I'm just going to comment on the JavaScript part.
The assignment asked for your menu
variable to be set up as an object rather than an array. The object keys should be taken from your favouriteBooks
array. For example:
let menu = {
"the-godfather": {
Title: "The godfather",
Language: "English",
Author: "Mario Puzo"
},
// etc
}
I have placed the key "the-godfather"
within quotes because that contains the -
character, which is not allowed in a JavaScript identifier. Had you chosen to replace spaces in by an underscore _
character, then you could leave out the quotes, like this:
let menu = {
the_godfather: {
Title: "The godfather",
Language: "English",
Author: "Mario Puzo"
},
// etc
}
With this setup, your favouriteBooks
array defines which books you wish to include in your web page and in what order. Your menu
object then just becomes a container for the book details.
Your for
loop needs to be adjusted a bit to make this work:
for (let i = 0; i < favouriteBooks.length; i++) {
const key = favouriteBooks[i];
const bookInfo = menu[key];
// You can now use bookInfo where you used menu[i] previously
}
In the for
loop body, you create an ul
and two li
elements. Those li
elements should be children of the ul
rather than the containing div
. You ul
is empty. I found this out by checking in the Chrome inspector the HTML that was generated by your program.
In the code where you add your images and links to the HTML you use hard-coded indexes (0, 1, etc) to access elements in your document. You should try and avoid that. It is better to keep the image and link data in an object and use a for
loop.
To give you an idea, check out this implementation of the assignment which I adapted from the homework submitted by Nagham.
https://github.com/remarcmij/class12-js/blob/master/week3/nagham-dom/homework3-2.js
Feedback Homework JS week 2
Hi Talal, here is my feedback on your homework:
General remarks:
- We recommend that you avoid
var
and always useconst
andlet
. - You have defined all of your functions as function expressions. While this is not an error, we recommend that you use function statements instead. I'll give an example in Q1.
Q1. Your sum()
function does not return the sum its tree arguments as was asked. It just writes the sum to the console. A correct implementation could be:
function sum(a, b, c) {
return a + b + c;
}
console.log(sum(4, 6, 8));
Q2. Ok, but take note of the general remarks I gave above.
Q3. Excellent (but see general remarks).
Q4. The code works correctly (but again: general remarks). You have re-assigned the argument code
to the type of vehicle. While there is nothing technically to stop you from doing that, it is considered a bad practice. For instance, when you do code = "car"
the variable code
no longer contains a code but now contains a vehicle type. So the name becomes misleading. It is better to create a new variable name. For instance:
function vehicleType(color, code) {
let type;
if (code === 1) {
type = "car";
} else if (code === 2) {
type = "motorbike";
} else {
console.log("the code is wrong");
}
console.log('A ' + color + ' ' + type);
}
Q5. We recommend that you always use 'strict' equality comparison: ===
. Three equals signs.
Q6. As in Q4, better not to re-assign the argumens but to introduce new variables. As a minor point, we asked to use the term used
rather than old
. Apart from that, the code works fine.
Q7. No issues.
Q8. Correct.
Q9. Do not re-assign the arguments. Introduce new variables. You can also make your code simpler by using code
as an index. For example:
function printVehicle(color, code, age) {
let condition;
if (age <= 2) {
condition = "new";
} else {
condition = "used";
}
let type = '';
if (code >= 1 && code <= vehicles.length) {
type = vehicles[code-1];
} else {
console.log("the code is wrong");
}
console.log('a ' + color + ' ' + condition + " " + type);
}
Why did you call your function newVehicle
? Clearly that is not what is does. If I call it with newVehicle("brown",1,5);
is prints out: a brown used cars
. Nothing 'new' here!
By the way, the output is not correct English. You can't use 'a' for a plural form of a word like 'cars'.
Q10. Almost perfect. I miss the final .
at the end the sentence.
I would have preferred a more meaningful name instead of u
. For instance lastVehicleType
or lastItem
.
Q11. Excellent!
Q12. Fine.
Q13. You probably intended Philip and Ivana to be two separate teachers. Apart from that it is fine.
Q14. Nice that you added the language property by executing code. Excellent.
Q15. While your code seems to output correctly, I'm afraid the implementation is not. Inside the foo()
function you should not reference the bar()
function. Instead you should call the function that was passed as an argument to foo()
.
Q16. When inspecting the output, what is your conclusion?
Q17. When inspecting the output, what is your conclusion?
Q18. When inspecting the output, what is your conclusion?
Feedback Strings & Arrays Week 3
Hi Talal,
Your code looks fine. Well done!
A general remark: it is best to avoid spaces in directory and file names. They often unnecessarily complicate things.
over JS week1 step3 HM
hi @talalalamdar , first of all well done but i have few points:
1 - NO VAR
2 - in excersize n(2) the perpuse is to use () so the best way to correct the console.log is: console.log('i'm awesome'), try it .
3 - in number (4) you don't need to redeclare the variable y but only to do : y = "hoi" because y is already being declared two lines above.
4 - in number (5) the if statment is ( if .. elseif .. ....else), you can't write if 2 times even if the result would be the same of yours.
5 - in number (8), when you are writing the if statment you missed on important thing , you have used && which means "and", imagine that three from your variables are strings and the forth is a number, in that case you will get a message "NONE OF THE VARIABLES ARE THE SAME TYPE" which is not true , i will leave it to you to find another way doing in and let me know when you solve it.
6 - goodluck**
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.