I am learning JavaScript and I am trying to print this particular sequence of hashes:
#
##
###
I wrote this piece of code to produce the sequence:
for(let i = 0; i < 3; i++){
for(let j = 0; j <= i; j++){
print('#');
}
print('\n');
}
Note: I am using rhino to execute the program on my Ubuntu terminal.
rhino <filename>.js //Command used to execute JavaScript file.
The output I obtain:
#
#
#
#
#
#
I obtain the correct output with this program:
var starString = "";
for(let i = 0; i < 3; i++){
for(let j = 0; j <= i; j++){
starString += '#';
}
print(starString);
starString = "";
}
My question is this: Is there a print statement which I can use that does not add a newline at the end of the statement?