I was coding something and wanted to generate either
const foo = 1 - 2 * Math.round(Math.random());
round() function and a
random() function. (Keep in mind that
Math.random() generates a number between 0 and 1; this is probably the only difference between languages.)
Hope it helps!