Generate a random sign
JavaScript
const randomSign = () => (Math.random() >= 0.5 ? 1 : -1)TypeScript
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)