Truth Problem

by Prathameshsb

JavaScript

"use strict"
/* This program should output the numbers 0, 1, 3, 6, and 10 to the console, with one number appearing on each line. */


let a = 5; // let keyword was missing inorder to define a variable

let b = 0;

let d;

for (let c = b; c < a; c = c + 1) { // it should have been c = c + 1 instead of c = c - 1 or else "c" will go to negative values.

  if (d == undefined) { // it should be "==" because we are checking and not assigning. 

    d = 0; // should be a number and not a string, so that is why it will not have the quotation marks.

  } else {

    d = d + c;

  } // there was 1 extra bracket here!
  console.log(d);
}