Skip to content

Instantly share code, notes, and snippets.

"scripts": {
"start": "react-app-rewired start",
"build": "react-app-rewired build",
"test": "react-app-rewired test --env=jsdom",
"eject": "react-scripts eject"
}
{
"plugins":[]
}
module.exports = {
extends: [
'react-app', // for editor
'eslint:recommended',
'plugin:prettier/recommended',
'prettier/react',
],
parser: 'babel-eslint',
plugins: ['babel'],
rules: {
{
"plugins":[
["@babel/plugin-proposal-pipeline-operator", { "proposal": "minimal"}],
]
}
function doubleSay (str) {
return str + ", " + str;
}
function capitalize (str) {
return str[0].toUpperCase() + str.substring(1);
}
function exclaim (str) {
return str + '!';
}
let result = exclaim(capitalize(doubleSay("hello")));
result //=> "Hello, hello!"
let result = "hello"
|> doubleSay
|> capitalize
|> exclaim;
result //=> "Hello, hello!"
function double (x) { return x + x; }
function add (x, y) { return x + y; }
function boundScore (min, max, score) {
return Math.max(min, Math.min(max, score));
}
let person = { score: 25 };
let newScore = person.score
|> double
|> (_ => add(7, _))
|> (_ => boundScore(0, 100, _));
newScore //=> 57
let person = { score: 25 };
let newScore = person.score
|> double
|> (num => add(7, num))
|> (num => boundScore(0, 100, num));
newScore //=> 57