-
Notifications
You must be signed in to change notification settings - Fork 0
Description
Hi Semih, here is my feedback on your homework.
In general: please use let and const instead of var.
Q1. Your function produces the product rather than the sum of its arguments. In that respect it doesn't meet the requirements of the assignment.
You have called your function maths and the arguments length, width and height. It returns the product of the arguments. So, it looks to me that your function could better be called computeVolume instead of math. But even that would be too limiting. If you called your function computeProduct and used generic names for your arguments the function would look more broadly usable:
function computeProduct(x, y, z) {
return x * y * z;
}Note that I have used a function statement rather than a function expression that you used. In general you should use function statements, like you did yourself in Q2.
Q2. Fine, except that I expected 'a red car' but got 'a red color'.
Q3. You don't need a function here and there is no need to use this (we haven't talked about this yet). You can simple use an object literal:
const myHouse = {
type: 'flat',
age: 5,
size: 'big'
};If I run you code as-is, it seems to work. But when I add a line 'use strict'; at the top of your file it produces a run-time error. Can you figure out why?
'use strict';
function myHouse(type, age, size) {
this.type = type;
this.age = age;
this.size = size;
console.log("My house is a " + this.type + " and it is " + this.age + " years.It's size " + this.size + " .");
}
myHouse("flat", 5, "big");Q4. Excellent, but use a function statement instead of a function expression.
Q5. Excellent.
Q6. Although strictly speaking your function produces the required output for vehicle("blue", 1, 5); it should produce correct output for any combination of allowed arguments. What if I wanted to see 'a red used motorobike' when calling it with `vehicle('red', 2, 7)?
Use a function statement.
Q7. OK
Q8. Excellent.
Q9-11. I'm missing your answers.
Q12. Yep.
Q13. Fine, but use let or const: const teachers = [
Q14. Excellent.
Q15. In your function foo() you should not make a reference to bar and car. You should only use the argument func.
Q16. OK, but what can you conclude from the produced output?
Q17. What if you change o2 like this:
o2.foo = 'not bar';Q18. I didn't see your answer.