vendredi 3 mars 2023

Advanced JavaScript Pattern Creation Problem

I am working on a project from my for fun, and I was asked the question "Write a program to output the letters H, T and L as created by * characters. Create four variables that store * patterns and use ONLY THOSE to output the letters."

So what I have to do is create text in the console looking like this

*          *
*          *
*          *
************
*          *
*          *
*          *

First I had to figure out how to create a vertical line stored in a variable. It took me a while, but I did it with the "/n" function. I got it, but can't figure out the rest of the problem. i ever  :

var side1 = "*********"
var side2 = "*"+ "\n" +"*"+ "\n" +"*"+ "\n" +"*"+ "\n" +"*"+ "\n" +"*"+ "\n" +"*"+ "\n" +"*"+ "\n" +"*"
console.log(side2)

If I one variable which is a horizontal line, and one that is vertical, how would I put them next to eachother?

This is really random because I keep on deleting and trying new things. Any ideas?

Aucun commentaire:

Enregistrer un commentaire