JSFiddle - React, Tailwind, and code Playground
by Sam88
JavaScript
t='';p=prompt();z=' ';r=z+p+z;for(d=9;d;d--){q='';for(i=0;i<p.length;i++)s=r.substr(i,3),q+=p[i]==d?'^':s==' /'|s==' ^'?'/':s=='\\ '|s=='^ '?'\\':s=='\\ /'|s=='^ /'|s=='\\ ^'|s=='^ ^'?'v':z;r=z+q+z;t+=!q.trim()?"":q+'\n'}alert(t)
//Changes
//p[i] instead of p.charAt(i)
//for condition d instead of d>0
//d initialized at 9
//add a line only if not empty when trimmed (!"" = true)
//also the output has a trailing newline, not shown in alert
//alert(t.splice(0,-1)) to eliminate it