Javascript Exercise#17

Hi, I can not execute this code due to error!

type or paste code here
let productdisplay = new Surfexcel(33, 'a');
let productdisplay1 = new Surfexcel(33, 'a');
console.log(areEqual(productdisplay));
console.log(areSame(productdisplay1));

function Surfexcel(age, name) {

    this.age = 30;
    this.name = 'ayub';




}

function areEqual(productdisplay, productdisplay1) {
    return productdisplay1.age === productdisplay.age && productdisplay1.name === productdisplay.name;
}

function areSame(productdisplay, productdisplay1) {

    return productdisplay1 === productdisplay;
}

Hi,

This works for me. Compare with your calls to areEqual and areSame. What is different ? Then why isn’t it working ?
If you observe it you’ll understand.

let productdisplay = new Surfexcel(33, 'a');
let productdisplay1 = new Surfexcel(33, 'a');
console.log(areEqual(productdisplay,productdisplay1));
console.log(areSame(productdisplay, productdisplay1));

function Surfexcel(age, name) {
    this.age = age;
    this.name = name;
}

function areEqual(productdisplay, productdisplay1) {
    return productdisplay1.age === productdisplay.age && productdisplay1.name === productdisplay.name;
}

function areSame(productdisplay, productdisplay1) {

    return productdisplay1 === productdisplay;
}

Answered here: JavaScript Part 1: 22-Exercise 6- Get Max - #5 by jmrunkle

1 Like