5 ms·
Care to elaborate? There are some nifty tricks when it comes to golfing JS.
by numlock86 6y ago
Care to elaborate? There are some nifty tricks when it comes to golfing JS.
- rukshn 6y agoWell sorry I was in a hurry when I typed the above comment Well the body can’t have any dom elements according to the challenger That means I had to create the dom elements as well and I was unable to figure out a way within the given character limit
- tdeck 6y agoI wonder if document.write() would work for you. The old-fashioned APIs from before the DOM era (e.g innerHTML, innerText) generally seem to be a lot shorter although they're still a bit verbose.
- rukshn 6y agoYes I guess that was the right way all along, I saw a comment on this thread using innerHtml and write
- bamboleo 6y agoJS is ok, it’s the DOM APIs that are verbose. I mean this is just to handle the enter key: f.addEventListener('keypress',e=>{if(e.keyCode==000) etc()})
- rukshn 6y agoExactly these were the challenges I faced when using plain js
- tdeck 6y agoJust a fun note: You can replace this f.addEventListener('keypress',e=>{...}) With the older but essentially equivalent f.onkeypress=e=>{...} and save 18 characters. You can even use `onkeyup` and save 3 more characters.