Skip to main content
Commonmark migration
Source Link

#JavaScript (ES6), 66 54 51 bytes#

JavaScript (ES6), 66 54 51 bytes

My first foray into code golf so I'm open to suggestions for improvements.

The following will output an array of the required years.

f=

_=>[...Array(121)].map((x,y)=>Date().split` `[3]-y)

console.log(f());


##History## ###54 bytes### _=>Array(121).fill(Date().split [3]).map((x,y)=>x-y) ###66 bytes### (y=[Date().split [3]],x=121)=>{while(x--)y[x]=(y[0]-x);return y}

History

54 bytes

_=>Array(121).fill(Date().split` `[3]).map((x,y)=>x-y)

66 bytes

(y=[Date().split` `[3]],x=121)=>{while(x--)y[x]=(y[0]-x);return y}

#JavaScript (ES6), 66 54 51 bytes#

My first foray into code golf so I'm open to suggestions for improvements.

The following will output an array of the required years.

f=

_=>[...Array(121)].map((x,y)=>Date().split` `[3]-y)

console.log(f());


##History## ###54 bytes### _=>Array(121).fill(Date().split [3]).map((x,y)=>x-y) ###66 bytes### (y=[Date().split [3]],x=121)=>{while(x--)y[x]=(y[0]-x);return y}

JavaScript (ES6), 66 54 51 bytes

My first foray into code golf so I'm open to suggestions for improvements.

The following will output an array of the required years.

f=

_=>[...Array(121)].map((x,y)=>Date().split` `[3]-y)

console.log(f());


History

54 bytes

_=>Array(121).fill(Date().split` `[3]).map((x,y)=>x-y)

66 bytes

(y=[Date().split` `[3]],x=121)=>{while(x--)y[x]=(y[0]-x);return y}
added 97 characters in body
Source Link
Shaggy
  • 43.5k
  • 4
  • 36
  • 94

#JavaScript ES6(ES6), 66 54 Bytes#54 51 bytes#

My first foray into code golf so I'm open to suggestions for improvements.

The following will output an array of the required years.

f=

_=>Array(121)_=>[.fill(Date().split` `[3].Array(121)].map((x,y)=>x=>Date().split` `[3]-y)

console.log(f());


##History## ###54 bytes### _=>Array(121).fill(Date().split [3]).map((x,y)=>x-y) ###66 bytes### (y=[Date().split [3]],x=121)=>{while(x--)y[x]=(y[0]-x);return y}

#JavaScript ES6, 66 54 Bytes#

My first foray into code golf so I'm open to suggestions for improvements.

The following will output an array of the required years.

f=

_=>Array(121).fill(Date().split` `[3]).map((x,y)=>x-y)

console.log(f());


##History## ###66 bytes### (y=[Date().split [3]],x=121)=>{while(x--)y[x]=(y[0]-x);return y}

#JavaScript (ES6), 66 54 51 bytes#

My first foray into code golf so I'm open to suggestions for improvements.

The following will output an array of the required years.

f=

_=>[...Array(121)].map((x,y)=>Date().split` `[3]-y)

console.log(f());


##History## ###54 bytes### _=>Array(121).fill(Date().split [3]).map((x,y)=>x-y) ###66 bytes### (y=[Date().split [3]],x=121)=>{while(x--)y[x]=(y[0]-x);return y}

deleted 300 characters in body
Source Link
Shaggy
  • 43.5k
  • 4
  • 36
  • 94

#JavaScript ES6, 6666 54 Bytes#

My first foray into code golf so I'm open to suggestions for improvements.

The following will output an array of the required years.

(y=[Date().split` `[3]],x=121)=>{while(x--)y[x]=(y[0]-x);return y}

##Try It##

f=

_=>Array(y=[Date121).fill(Date().split` `[3]],x=121`[3])=>{while.map(x--)y[x]=(y[0]-x,y);return =>x-y};)

console.log(f());

 

##Ungolfed## const getyears=()=>{##History## let array=new Array();###66 bytes### let year=array[0]=parseInt(new Datey=[Date().getFullYear()split [3]],x=121); let x=0; =>{while(x<120x--){ array.pushy[x]=(yeary[0]-x); x=x+1; } return array; ;return y} console.log(getyears().join(","));

#JavaScript ES6, 66 Bytes#

My first foray into code golf so I'm open to suggestions for improvements.

The following will output an array of the required years.

(y=[Date().split` `[3]],x=121)=>{while(x--)y[x]=(y[0]-x);return y}

##Try It##

f=(y=[Date().split` `[3]],x=121)=>{while(x--)y[x]=(y[0]-x);return y};
console.log(f());

##Ungolfed## const getyears=()=>{ let array=new Array(); let year=array[0]=parseInt(new Date().getFullYear()); let x=0; while(x<120){ array.push(year-x); x=x+1; } return array; } console.log(getyears().join(","));

#JavaScript ES6, 66 54 Bytes#

My first foray into code golf so I'm open to suggestions for improvements.

The following will output an array of the required years.

f=

_=>Array(121).fill(Date().split` `[3]).map((x,y)=>x-y)

console.log(f());

 

##History## ###66 bytes### (y=[Date().split [3]],x=121)=>{while(x--)y[x]=(y[0]-x);return y}

Source Link
Shaggy
  • 43.5k
  • 4
  • 36
  • 94
Loading