Construir un Generador de Pirámides. - Generar un pirámide

Cuéntanos qué está pasando:

It’s asking me to create a function called “pirámide,” but the validator doesn’t accept quotation marks because it’s programmed in English. So I typed the word “pyramid” to try and get it to work, but it’s not working. It keeps asking me to type “pirámide” exactly, but it’s not working.

Tu código hasta el momento

function pyramid(char, rows, bool) {
  let result = "\n";
  const rows = [];

  for (let i = 1; i <= rows; i++) {
    const spaces = " ".repeat(rows - 1);
    const content = char.repeat(2 * i -1);
    rows.push(spaces + content);
  }
  if(bool) {
    rows.reverse();
  }
  result += rows.join("\n") + "\n";
  return result;
}

console.log(pyramid("*", 3, false));
console.log(pyramid("#", 3, true));

Información de tu navegador:

El agente de usuario es: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/145.0.0.0 Safari/537.36

Información del Desafío:

Construir un Generador de Pirámides. - Generar un pirámide

Hi there!

You are correct to use the English ‘pyramid’ for the name…apparently there was a translation glitch in the instructions. But I’m seeing a syntax error in the console:

SyntaxError: unknown: Identifier 'rows' has already been declared. (1:23)

> 1 | function pyramid(char, rows, bool) {
    |                        ^
  2 |   let result = "\n";
  3 |   const rows = [];
  4 |

Happy coding!

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.