I am writing this factory function in the index.js file. But it is not working. In the console it is showing that the ‘rectangle1’ is undefined. Please find the error.
function createRectangle(len,bre) {
let rectangle = {
length: len,
breadth: bre,
draw: function() {
console.log('drawing rectangle');
}
};
return rectangle;
}
let rectangleObj1 = createRectangle(5,4);