Skip to content

Instantly share code, notes, and snippets.

let list = [true, true, true];
list[1] && console.log('list[1] is something ; ok');
list[5] && console.log('list[5] is something ; err');
if (list[1]) {
console.log('if list[1] ; ok');
}
if (list[5]) {
@jflessau
jflessau / postman-set-token-from-request.js
Last active December 15, 2019 17:25
Set environment variable to value from response data in postman.
// this goes into the "test" tab in postman
var response = JSON.parse(responseBody);
postman.setEnvironmentVariable("ENV_VAR_NAME", response.token);
@jflessau
jflessau / up.js
Last active October 31, 2019 10:37
React: Hook for scrolling a page all the way up.
import { useState, useEffect } from 'react'
export default function useScrollUp() {
const [init, setInit] = useState(true)
useEffect(() => {
if (init) {
window.scrollTo(0, 0)
setInit(false)
}