🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: HTTP Methods, Status Codes and Headers: all 10 questions

Quiz: HTTP Methods, Status Codes and Headers · Question 5 of 10

What does this print? (code)

What does this print?

const codes = [201, 404, 503, 302];
console.log(codes.map((c) => Math.floor(c / 100) + "xx").join(" "));
  1. A.2xx 3xx 4xx 5xx
  2. B.2xx 4xx 5xx 3xx
  3. C.201xx 404xx 503xx 302xx
  4. D.2 4 5 3
Answer & explanation

Correct answer: 2xx 4xx 5xx 3xx

Dividing by 100 and flooring gives the first digit, which is the status family.

Can you get the rest right without peeking?

Take the timed Quiz: HTTP Methods, Status Codes and Headers quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →