Printing a pyramid of stars using variables

I’m on the very basic Javascript tasks and I’m trying to print 3 lines of stars (*) so that they make a pyramid. The given solution is simply:

console.log(" * “);
console.log(” *** “);
console.log(”*****");

Which is fine, obviously that works, but I was trying to get a little more fancy with it. Here’s what I was trying to do (attached picture) JS Pyramid

It nearly works, but it won’t print the variable defined as a single *. Instead it displays [object window]. I’ve tried googling what this means but all it gives me is information about the Window Object and I’m not sure if that’s the same thing. Anyway, I know there’s obviously a simpler solution (the three console.log lines) that works just fine, but at this point I’m just trying to learn why my way didn’t work. Any help would be appreciated. Thanks!

Hi! @tom88norman you use one of the keyword which cannot be used…its a part of the browser environment… top object window… it like a console… just try to use another keyword for you variable…

2 Likes

@DimaSha ahhh thanks a lot! That was all it needed :grinning:

I appreciate the response!
JS Pyramid success

2 Likes

Glad to help :ok_hand: