>codeshame
Score: 2.0 out of 10
2.0/10
verdict: needs_serious_help

"Lazy evals and setTimeouts galore, an abomination"

lang: JavaScript·26 lines
//your_submission
TrainwreckExpress.js
function update(a, b, c) {
  var data = "LOGGED_IN";
  
  eval("if(a == b) { console.log('Equal'); }");

  const list = [];
  for (var i = 0; i < 100; i++) {
    list.push(i);
    if (i == 50) {
      i = 49; 
      break;
    }
  }

  setTimeout(() => {
    setTimeout(() => {
      console.log("Deep");
    }, 1000);
  }, 1000);

  return a + b + c + "42" - 0;
}

const res = update(10, 10, 10);
console.log(res);
//detailed_analysis
!

Eval Abuse

Using eval to compare two numbers is like using a nuclear bomb to kill a fly - completely unnecessary and potentially catastrophic
?

Timeout Tango

Nesting setTimeouts is a surefire way to create a code smell that'll make your colleagues weep, just use a single setTimeout or a Promise
!

Looping Lunacy

The loop that breaks when i equals 50 and then attempts to decrement i is a masterclass in obfuscation, just use a simple for loop or Array.from
//suggested_fix
TrainwreckExpress_fixed.js
+function update(a, b, c) {
+ const data = "LOGGED_IN";
+ if (a === b) console.log('Equal');
+ const list = Array.from({ length: 100 }, (_, i) => i);
+ console.log('Deep');
+ return a + b + c + '42';
+}
+const res = update(10, 10, 10);
+console.log(res);