# Chapter 10f Exercise

Hey there, I am stuck on step F of the chapter 10 exercise. Below is my attempt that was nearly successful. The output is the five hashes but with only a single space. I mitigate that by just making spaces three spaces instead of just the one but I feel like that is just going to give me more problems moving to the next step where I make the triangle.

function makeSpaceLine(numSpaces, numChars){
let line = makeLine(numChars);
for (let i = 0; i < numSpaces; i++){
spaces = " ";
spacedLine = spaces + line + spaces;
}
return spacedLine;
}

1 Like

Or you can also do 2 loops. 1 for your spaces & 1 for your chars.

1 Like

Edit: used this function thru Diamonds and worked fine.
@woodc555 - below worked for step F; then worked when called in step G; very close to yours but please notice += on space equation in for loop. I will go onto Diamonds now.
Do all think below will work going forward to Diamonds?
I did not use @CedricH .repeat() method or @StephNau 2 loops -
function makeSpaceLine(numSpaces, numChars) {
let space = ‘’;
let spaceline = ‘’;
line = makeLine(numChars);
for (let i=0; i<numSpaces; i++){
space += " ";
}
spaceline = space + line + space;
return spaceline;
}
console.log(makeSpaceLine(3,5));

1 Like

Hi guys, thanks for the help above!