Username: 
Password: 
Restrict session to IP 

Javascript golf

Global Rank: 243
Totalscore: 89476
Posts: 1675
Thanks: 1356
UpVotes: 913
Registered: 16y 272d




Last Seen: 16s
The User is Online
Javascript golf
Google/translate0Thank You!0Good Post!0Bad Post! link
A few years ago someone brought up javascript minigolf.

Here is another task:

GeSHi`ed javascript code
1
2
3
4
5
 
var input = 'some.tree.structure.to.parse';
 
var wantedOutput = ['some', 'some.tree', 'some.tree.structure', 'some.tree.structure.to', 'some.tree.structure.to.parse'];
 


Happy putting!
The geeks shall inherit the properties and methods of object earth.
Global Rank: 202
Totalscore: 101919
Posts: 65
Thanks: 67
UpVotes: 44
Registered: 15y 298d
xen`s Avatar






The User is Offline
RE: Javascript golf
Google/translate1Thank You!1Good Post!0Bad Post! link
i did indeed Smile
to get the ball rolling my first attempt: 94
GeSHi`ed javascript code for parse
1
function go(s){var l=n=s.split(".");l=n.length;for(i=1;i<l;i++){n[i]=n[i-1]+'.'+n[i]}return n}
chmod ---x--x--x,, i'm illiterate!
Global Rank: 202
Totalscore: 101919
Posts: 65
Thanks: 67
UpVotes: 44
Registered: 15y 298d
xen`s Avatar






The User is Offline
RE: Javascript golf
Google/translate1Thank You!1Good Post!0Bad Post! link
first one made tidy: 84

GeSHi`ed javascript code
1
function go(s,n=s.split(".")){for(i=1;i<n.length;i++){n[i]=n[i-1]+'.'+n[i]}return n}
chmod ---x--x--x,, i'm illiterate!
Global Rank: 33
Totalscore: 307841
Posts: 181
Thanks: 181
UpVotes: 203
Registered: 16y 255d
livinskull`s Avatar





Last Seen: 2d 11h
The User is Offline
RE: Javascript golf
Google/translate1Thank You!1Good Post!0Bad Post! link
xen's code 2 chars shorter: 82

GeSHi`ed javascript code
1
function go(s,n=s.split(d=".")){for(i=1;n.length-i;)n[i]=n[i-1]+d+n[i++];return n}


I'm trying to come up with sth on my own, but with that functional approach it keeps getting too long Drool
Speaking of functional, maybe sth recursive could be nice..
Global Rank: 202
Totalscore: 101919
Posts: 65
Thanks: 67
UpVotes: 44
Registered: 15y 298d
xen`s Avatar






The User is Offline
RE: Javascript golf
Google/translate0Thank You!0Good Post!0Bad Post! link
glad you didn't take cheap trick, function name 'g'<'go' one less.
chmod ---x--x--x,, i'm illiterate!
Global Rank: 199
Totalscore: 104730
Posts: 24
Thanks: 41
UpVotes: 24
Registered: 16y 225d

The User is Offline
RE: Javascript golf
Google/translate1Thank You!1Good Post!0Bad Post! link
75 chars here:

GeSHi`ed javascript code
1
function g(s){i=s.lastIndexOf('.');return~i?g(s.substr(0,i)).concat(s):[s]}
tunelko, awe, quangntenemy, TheHiveMind, Z, balicocat, Ge0, samuraiblanco, arraez, jcquinterov, hophuocthinh, alfamen2, burhanudinn123, Ben_Dover, stephanduran89, braddie0, SwolloW, dangarbri have subscribed to this thread and receive emails on new posts.
1 people are watching the thread at the moment.
This thread has been viewed 6506 times.