Chapter 10.10.1 B

What won’t the following functions make a square?

function makeLine(size){
let hashTag = “#”;
let newHash = “”;
for (i=0;i<size;i++){
newHash = newHash + hashTag
}
return newHash
}

function makeSquare(size){
let square="";
for (i=0;i<size;i++){
console.log(\n ${makeLine(size)})
}

}

console.log(makeSquare(3))

There are backticks here, they just don’t show up here for some reason.

This won’t either. Very stuck!

function makeLine(size){
let hashTag = “#”;
let newHash = “”;
for (i=0;i<size;i++){
newHash = newHash + hashTag
}
return newHash
}

function makeSquare(size){
let square = makeLine(size);
let newSquare = “”;
for (i=0;i < size;i++){
newSquare = newSquare + square
}
return square
}

console.log(makeSquare(3))

nope again

function makeSquare(size){
let square = makeLine(size);
let newSquare = “”;
for (i=0;i < size;i++){
newSquare = newSquare + square + ‘\n’
}
return square
}

console.log(makeSquare(3))

since I’m talking to myself here.

The answer is: don’t forget the work “let” when creating for loops.