javascript - remove all Decimals and single numbers from array / string -
so script generates big blob of "piano notes" similar to...
var songnotes = "...";
and problem between piano notes need [also in fiddle] there empty ",," , decimal numbers.. cant figure out how remove empty ,, , decimals big "1.0416666666642413,0.625,0,g3,1498.9583333333358,,0,c3,1.0416666666642413,0.625,0,c3" , want them removed except the needed words are
var therightones = "s2,as2,cs3,ds3,fs3,gs3,as3,gs3,cs4,ds4,fs4,cs3,as4,gs4,ds5,a2,cs4,b2,c3,a3,ds4,b3,c4,as3,gs2,e3,c3,c4,cs3,ds3,a4,fs3,gs3,as3,g3,f3,b4,c5,a3,d4,as2,e4,g4,d3,b3,b2,f4,a2,d4,e4,cs5,gs1,e2,c2,c3,cs2,ds2,a3,fs2,gs2,as2,g2,f2,b3,c4,a2,d3,as1,e3,g3,d2,b2,b1,f3,a1,d5,e5";
so can give me clue on how can accomplished? if needs more info ready oblige so..
regards - adarsh hegde
var notesarr = songnotes.split(","); var len = notesarr.length; while(len--) { if(!notesarr[len] || !isnan(parseint(notesarr[len], 10))) { notesarr.splice(len, 1); } } songnotes = notesarr.join(",");
Comments
Post a Comment