Giter VIP home page Giter VIP logo

hyf-javascript1's People

Contributors

abdullahweb avatar

hyf-javascript1's Issues

Feedback DOM manipulation

Hi Abdullah,

Here is my feedback on your DOM manipulation homework.

  • You have defined the array movieTitles but you are not using it anywhere.
  • I also noted that you are not adding the Writer and Director information to your web page.
  • You have defined a variable newObj which is actually an array.

Please look at a possible implementation of the homework that I adapted from Nagham's homework submission this week. Carefully study the code and compare it with was asked in the homework assignment. As always, feel free to ask questions on slack.

https://github.com/remarcmij/class12-js/tree/master/week3/nagham-dom

JS Week 3 - Strings and Arrays

Hi Abdullah,

Your code looks good, and you mostly use let, but there are some parts where you're still using var . You might want to stick to let and const in the future.

For 2.1, you were supposed to add "turtle" to the array and not "Mauro's" as you did.

For 2.9 and 2.10, I don't think it was necessary to delete meerkat from the array. All that was asked was to find its index position and log it.

Strings & Arrays Week 3

Hi Abdullah,

Strings: Please use let and const instead of var. What does newRE mean? Can you think of a better name? What about something like readableString?

Arrays:

  • Mauro's favourite animal is a turtle so I would expect to find turtle in the array, not Mauro's.
  • The indexOf method returns the index (>= 0) of the item you are looking for or -1 if the item is not found. In your if statement you are using as condition i:
if (i) {
    favoriteAnimals.splice(i, 1);
}

What if meerkat was found at position 0 (when meerkat was the first element in the array). Then, in your code, the splice was not done because 0 is 'falsy'. The correct way to do it is:

if (i !== -1) {
    favoriteAnimals.splice(i, 1);
}

Apart from that everything is in working order.

Dom assignment

Hi abdullah, i checked your code for the DOM assignment , it is good but i have some notes :
1- try to use (let) instead of (var).
2- you could also create a header in your JavaScript file instead of creating it in the HTML file.
3- you can also create a unique a cover for each movie, either using a for loop or by separated statements
4- there are also problem with your function i think it doesnt display the title, writer, and director. you has created it but you didnt append them to your divs.
good luck with fixing them and if you want help let me know :) .

Feedback Homework JS week 2

Hi Abdullah, here is my feedback on your homework.

In general: please use let and const instead of var.

Q1. You must declare your variable result with a let or const:

const sum = function (num1, num2, num3) {

  const result = num1 + num2 + num3;

  return result;
};

You have used a function expression to define your function. I have preference for a function statement. Also you don't need to use an intermediate variable result. You can return the value directly, resulting in:

function sum(num1, num2, num3) {
  return num1 + num2 + num3;
}

Q2. As in Q1, you need to declare your result variable with const or let. Or leave it out entirely, as in:

function colorCar(color) {
  return `a ${color} car`;
}

Q3. Your variable bigBox is not an object, it is an array (although typeof would say 'object' we consider it an array).

Q4. console.log() does not return a value (actually it returns undefined). Your vehicleType() function is also not required to return anything. It just needs to print out a message. If I run your code I get:

a blue car
undefined

Where does that undefined come from, you think?

Q5. console.log(3 === 3); works fine for me.

Q6. See Q4 for console.log issue. How can a vehicle that is 5 years old be used and a vehicle that is 6 years old new? And what about vehicles that are 1 year old or 7 years old or any other age other than 5 or 6?

Q7/8. Why do you think you need a for loop. That for loop doesn't do anything useful other than looping. If I remove the loop your code still works fine.

Q9. Same issue with console.log. And same issue with age. If I change age to 4 as in console.log(vehicleType('blue', 4, 1)); I get printed undefined. Your function should work for all possible values for color, age and type.

Q10/11. Can you make your code work if I change your code like this?

const list = [
  { type: 'motorbikes' },
  { type: 'caravans' },
  { type: 'bikes' },
  { type: 'cars' }
];

list.push({type: 'truck'});

let vehicles = "";

for (let index = 0; index < list.length; index++) {
  vehicles = vehicles + list[index].type + ", ";
}

console.log(`Amazing Joe's Garage, we service`, vehicles);

Q12. Your 'empty' object is actually a (non-empty) array with three empty objects. I would consider the following an empty object:

const emptyObject = {};

Q13/14. You actually created an array, but perhaps that is better here than just an object.

Q15. You got this one right. Well done.

Q16. The === operator does not check the values of the objects/arrays. In fact, in this assignment you wouldn't see any difference between == and ===. The triple equal sign is for 'strict' comparison and does not convert the types of the two values it compares. The == operator does convert the types if necessary. For instance:

1 == '1'; // => true
1 === '1'; // => false

Q17. So what happens to o1 and o3 if I do this:

o2.foo = 'not bar';

Q18. typeof bar returns a string and the type of a string is 'string'. That how I should read your answer, right?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.