Code Lab

Timer: 3 min, like in an interview. Hints and autocomplete are off while it runs

String plus number

EasyBasics3 min

What does this program print? Write the output: one line for each console log call, in the same order.

const s = 21 + 'abc' + 49 + 14;
console.log(s);

const t = 21 + 49 + 'abc' + 14;
console.log(t);
  • The program mixes numbers and strings with +. Think about when + adds numbers and when it joins text (concatenation), and when JavaScript turns a number into a string by itself (type coercion).
  • Type each line exactly as the console shows it: a string is printed without quotes.

Asked at Mastercard · Source

Your answer
Loading the editor...
Press Run to see the test results here