Implementing Modules in Node

/* shape-area.js */
const PI = Math.PI;
const ca = {
    return PI*a*a
    return a*b
module.exports = ca
/* app.js */ 

const ca = require('./shape-area.js');
const circleArea = ca.circleArea;
const squareArea = ca.squareArea;
const areaOfCircle = circleArea(3);
const areaOfSquare = squareArea(2,4);

When i was practicing this lession,there was something wrong with the last code. When squareArea() function with parameters (2,4) was called, number 8 should be printed, i don’t know why number 4 was printed.So why it goes wrong? And how can i solve this problem?


Area of a square should not have 2 different arguments passed, because all sides of a square are equal. Try passing 1 argument instead and see if that changes the answer? I’m currently working through this same article on Learn Intermediate JS as well, so I feel you on this one. Happy keyslappin!

edit: alos just noticed that SquareArea is not declared as an object property? That might be where the math is gettin foo’d up. Let me know when you solve (or if u already solved) this code challenge. Your post is helping me work thru this right now!