I am very new to programming, so this might be a simple solution that I simply don't know. I have been trying to write a code that takes a specific number, for example "10", and returns a pyramid where the base has the number of asterisks matched by the value you enter. We are supposed to use this in our code:
function makeLine(length) {
var line = "";
for (var j = 1; j <= length; j++) {
line += "* "
}
return line + "\n";
}
For example:
image of triangle where the base is matched by the number entered by the programmer
My code so far looks like this. I know it's completely wrong because I am not at all getting the required results. What am I doing wrong??
function makeLine(length) {
var line = "";
for (var j = 1; j <= length; j++) {
line += "* ";
}
return line + "\n";
function makeTriangle(length) {
var line = "";
for (var j = 1; j <= length; j--) {
line += "* ";
}
}
}
console.log(makeTriangle(8));