I NEED CORRECTION IN EXERCISE 1 STORE 1 :
OOJS: Task 1
function Shape(name, sides, sideLength) {
this.name = name;
this.sides = sides;
this.sideLength = sideLength;
// function that does the calculation
this.calcPermiter = function(){
return console.log((this.sides)*+this.sideLength)
}
}
// add a new instance to Shape
let square = new Shape("Square", 2,5)
square.calcPermiter();
let triangle = new Shape("triangle", 2,3)
triangle.calcPermiter()
(no script tag I took to load the code on the site)
FOLLOW THE EXERCISE LINK : https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Objects/Test_your_skills:_Object-oriented_JavaScript
Hello @Hacker_Man_De_Souza
you doing great well done
just little thing
replace this
Shape.calcPermiter
also you have type here
return console.log((this.sides)*+this.sideLength)
you write *+ which not valid
hope that help and have a nice day 
with this
Shape.prototype.calcPermiter
1 Like
cause you either multiplay or add but what will *+ do ?
the only thing that close to that is *= or += which
x += y mean x = x + y
x *=y mean x = x * y
there no +*
hope that help and have a nice day 
1 Like
Is repeating
side * 6
(this side) + (this side) + (this side) + (this side) + (this side) + (this side)
My side variable is accumulating the values while my sideLength will be as many times as the side will repeat doing the perimeter calculation …
since the calculation of the Permiter for triangle is different than the square you need to create 2 make triangle and square subclass of shape
then write Permiter function for each one since the calculations is different
The program returns the 2 correct values of the Triangle and Square perimeter
console.log (10) - square
console.log (6) - triangle
it worked perfectly I didn’t understand what you wanted to show me The program returns the 2 correct values of the Triangle and Square perimeter
console.log (10) - square
console.log (6) - triangle
it worked perfectly I didn’t understand what you wanted to show me
sorry it’s my bad i reread the questions and you are right
it the sides f the triangle are equal that why you do not need to do that
just multiplay the number of sides by the side length
sorry for my miss understand
1 Like