Skip to main content
Commonmark migration
Source Link

#JavaScript (ES6), 104 102 bytes

JavaScript (ES6), 104 102 bytes

Returns a Promise containing a JSON object for truthy or undefined for falsey.

n=>fetch(`//api.stackexchange.com/questions/${n}?site=codegolf`).then(r=>r.json()).then(j=>j.items[0])

##Try it

Try it

f=
n=>fetch(`//api.stackexchange.com/questions/${n}?site=codegolf`).then(r=>r.json()).then(j=>j.items[0])
oninput=_=>f(+i.value).then(console.log);f(i.value=1).then(console.log)
<input id=i type=number>

#JavaScript (ES6), 104 102 bytes

Returns a Promise containing a JSON object for truthy or undefined for falsey.

n=>fetch(`//api.stackexchange.com/questions/${n}?site=codegolf`).then(r=>r.json()).then(j=>j.items[0])

##Try it

f=
n=>fetch(`//api.stackexchange.com/questions/${n}?site=codegolf`).then(r=>r.json()).then(j=>j.items[0])
oninput=_=>f(+i.value).then(console.log);f(i.value=1).then(console.log)
<input id=i type=number>

JavaScript (ES6), 104 102 bytes

Returns a Promise containing a JSON object for truthy or undefined for falsey.

n=>fetch(`//api.stackexchange.com/questions/${n}?site=codegolf`).then(r=>r.json()).then(j=>j.items[0])

Try it

f=
n=>fetch(`//api.stackexchange.com/questions/${n}?site=codegolf`).then(r=>r.json()).then(j=>j.items[0])
oninput=_=>f(+i.value).then(console.log);f(i.value=1).then(console.log)
<input id=i type=number>

added 123 characters in body
Source Link
Shaggy
  • 43.5k
  • 4
  • 36
  • 94

#JavaScript (ES6), 104104 102 bytes

n=>fetch(`//api.stackexchange.com/questions/${n}?site=codegolf`).then(r=>r.json()).then(j=>!!j.items[0])

Returns a Promise containing a JSON object for truthy or undefined for falsey.

n=>fetch(`//api.stackexchange.com/questions/${n}?site=codegolf`).then(r=>r.json()).then(j=>j.items[0])

##Try it

f=
n=>fetch(`//api.stackexchange.com/questions/${n}?site=codegolf`).then(r=>r.json()).then(j=>!!jj=>j.items[0])
oninput=_=>f(+i.value).then(console.log);f(i.value=1).then(console.log)
<input id=i type=number>

#JavaScript (ES6), 104 bytes

n=>fetch(`//api.stackexchange.com/questions/${n}?site=codegolf`).then(r=>r.json()).then(j=>!!j.items[0])

##Try it

f=
n=>fetch(`//api.stackexchange.com/questions/${n}?site=codegolf`).then(r=>r.json()).then(j=>!!j.items[0])
oninput=_=>f(+i.value).then(console.log);f(i.value=1).then(console.log)
<input id=i type=number>

#JavaScript (ES6), 104 102 bytes

Returns a Promise containing a JSON object for truthy or undefined for falsey.

n=>fetch(`//api.stackexchange.com/questions/${n}?site=codegolf`).then(r=>r.json()).then(j=>j.items[0])

##Try it

f=
n=>fetch(`//api.stackexchange.com/questions/${n}?site=codegolf`).then(r=>r.json()).then(j=>j.items[0])
oninput=_=>f(+i.value).then(console.log);f(i.value=1).then(console.log)
<input id=i type=number>

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

#JavaScript (ES6), 104 bytes

n=>fetch(`//api.stackexchange.com/questions/${n}?site=codegolf`).then(r=>r.json()).then(j=>!!j.items[0])

##Try it

f=
n=>fetch(`//api.stackexchange.com/questions/${n}?site=codegolf`).then(r=>r.json()).then(j=>!!j.items[0])
oninput=_=>f(+i.value).then(console.log);f(i.value=1).then(console.log)
<input id=i type=number>