>
shame_leaderboard
// the most roasted code on the internet
// the most roasted code on the internet
let data:any=[1,"2",null,()=>42,{x:1}]; function chaos(a:any){let r:any=[];for(let i in a){let v=a[i];if(typeof v=="number")r.push(v+""+Math.random());else if(typeof v=="string")r.push(parseInt(v)+Math.random());else if(v==null)r.push(i+i);else if(typeof v=="function")r.push(v()+Math.random());else r.push(v.x??"??")}return r.sort(()=>0.5-Math.random())} (data as any).foo="bar";console.log(chaos(data), (data as any).nope?.x?.y ?? chaos({a:undefined}));var x:any={a:1,b:"3",c:[null,2],d:()=>({z:5})}; function bad(o:any){let r:any={};for(let k in o){let v=o[k];if(typeof v=="number")r[k]=v/Math.random();else if(typeof v=="string")r[k]=v*v;else if(Array.isArray(v))r[k]=v.map((i:any)=>i??k).join("");else if(typeof v=="function")r[k]=bad(v());else r[k]=JSON.stringify(v)+Math.random()}return Object.values(r).sort(()=>Math.random()-0.5)} (x as any).y?.z=(x as any).y?.z??bad(x);console.log(bad(x));type Order = { id: number; price: number; discount?: number }; function calcTotal(orders: Order[]): number { return orders .map(o => o.price - (o.discount ?? 0)) .filter(v => v > 0) .reduce((sum, v) => sum + v, 0);} const orders: Order[] = [ { id: 1, price: 100, discount: 10 }, { id: 2, price: 50 }, { id: 3, price: 30, discount: 40 }]; console.log(calcTotal(orders));