how to convert this C# code snippet to Javascript -
this question has answer here:
- repeat string - javascript 29 answers
i need understand how javascript handles new string object in c# code below
var upperbound = 14; (int = 0; < upperbound; i++) { console.writeline(new string('*', i)); } console.readline();
this how did in javascript:
var upperbound = 14; for(var i=0;i<upperbound;i++){ console.log(new string("*", i)); }
am newbie in programming , started off javascript if appear dumb asking question pls pardon , assist me explaining.. thanks
there no equivalent new string("*", i)
in js. need repetition yourself.
a handy hack array(i + 1).join("*")
, not efficient don't think, needs construct array. best way loop , concatenate.
Comments
Post a Comment