In this post, we will be looking at a few interesting (but could be challenging) JavaScript questions.
Most of them are actually testing the so-called “down-side” of JavaScript. You certainly should not write such code in a real-world codebase. As I have repeated many times, code should be clear, precise and concise, in that order of importantce. Nevertheless, they are indeed good questions to test your competency in JavaScript.
9 or 10?
You are given a function called magic_length
, which is defined as follows:
1 | function magic_length(input) { |
Please give one possible value of input
such that magic_length(input)
will return true
. Notice: input
should be of basic data type provided by built-in libraries.