Test 2 -ASCII-Art

by Shawn Wood

HTML

<script src="https://cdnjs.cloudflare.com/ajax/libs/mocha/2.1.0/mocha.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/mocha/2.1.0/mocha.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/mocha/2.1.0/mocha.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/chai/1.10.0/chai.min.js"></script>
<div id="mocha"></div>
<div id="result"></div>

JavaScript

/** Prints out ASCII-art in the shape of the capital letter L
 * @function 
 * @name solution
 * @param {integer} N - Number of rows and the number of characters displayed on the last row
 */
function solution(N) {
  // write your code in JavaScript (Node.js 8.9.4)
  // Set the string result
  let result = "";
  // Check the validation for min and max
  if (N >= 1 && N <= 100) {
    for (var i = 0; i < N; i++) {
      let rows = N - 1;
      if (i < rows) {
      result += 'L' + '<br>';
       
      }
      else {
      	 for (let j = 0; j < N; j++) {
					result += 'L';
        }
      }
    }
  }

  return result;

}
document.getElementById('result').innerHTML = solution(6);