How do I make a ladder from symbols in JavaScript?

  • 0
    Help make a ladder from the condition symbols as follows:
    3 variables are created into which data is entered
    1) The number of steps - cannot be equal: NaN, 0 and null. Keep asking for input until you get a number;
    2) indentation character - cannot be empty, the check will continue until the correct result is received;
    3) end character = end character cannot be empty, the check will continue until the correct result comes;
    By looping and gluing you should create a staircase.
    all steps are displayed in the developer console
    For example:
    variable quantity = 5
    variable indentation character = -
    variable end character = *

    result:
    *
    - *
    - *
    --- *
    ---- *
    JavaScript Anonymous, Nov 15, 2020

  • 2 Answers
  • 0
    Loop over from zero to "number", displaying at each step the required number of indentation characters and the final character.

    https://jsfiddle.net/93vwmx2j/
    Cole Gardner

  • 0
    for (let i = 0; i < 5; i++) {
    let line = ''
    for(let j = 0; j < i; j++) {
    line += '_'
    }
    console.log(`${line}*`)
    }
    Anonymous

Your Answer
To place the code, please use CodePen or similar tool. Thanks you!