50% Probability with JS/TS (m/f example)

PHOTO EMBED

Sat Nov 07 2020 23:04:05 GMT+0000 (Coordinated Universal Time)

Saved by @robertjbass #javascript #typescript

let rand = Math.random()
rand < 0.5 ? gender = 0 : gender = 1
this.name = `${gender ? '๐Ÿ‘ฉโ€๐Ÿ’ผ' : '๐Ÿ‘จโ€๐Ÿ’ผ'} ${faker.name.firstName(gender)} ${faker.name.lastName(gender)}`
content_copyCOPY

This example was used when generating a male or female name with faker.js to indicate the emoji for that person with a 50% chance between male or female