JavaScript version
randomSign.js
const randomSign = () => (Math.random() >= 0.5 ? 1 : -1);
TypeScript version
randomSign.ts
const randomSign = (): number => (Math.random() >= 0.5 ? 1 : -1);
const randomSign = () => (Math.random() >= 0.5 ? 1 : -1);
const randomSign = (): number => (Math.random() >= 0.5 ? 1 : -1);