I have created a class with a constructor and a method, I'm trying to create new instances and to use the inner function but it doesn't work, i'm new to JavaScript
I have tried to do this with getting the function outside of the class but i'm trying to do it while it's inside
class Jewel {
constructor(type, price) {
this.type = type;
this.price = price;
}
getHigherPrice(jewel1Price, jewel2Price) {
if (jewel1Price > jewel2Price) {
return jewel1.price;
} else {
return jewel2.price;
}
}
}
let biggerPrice = Jewel.getHigherPrice(new Jewel("bracelet", 300), new Jewel("ring", 200));
I want it to print the bigger price but it prints the second one