Here's a collection of our most... interesting, shall we say, coding endeavors
while (true) {
console.log("We're stuck in this loop and we can't escape");
break;
}
A classic. We've been trying to get out of this loop for hours, but it just keeps going.
var str = "Hello, world!";
str = str.replace(/h/i, 'H');
str = str.replace(/o/i, 'O');
str = str.replace(/, /, ', ');
console.log(str);
We're not even sure what this code does, but it looks nice and fancy.
function addTwoNumbers(a, b) {
if (typeof a === "number" && typeof b === "number") {
if (a === 1 || b === 1) {
if (a === 1 && b === 1) {
return 2;
} else if (a === 1) {
return a;
} else if (b === 1) {
return b;
}
} else {
return a + b;
}
} else {
return "Invalid input";
}
}
It's like trying to solve a puzzle while blindfolded.