DEV Community

Cover image for Top 30 Javascript Interview Warmup Exercises

Top 30 Javascript Interview Warmup Exercises

Theofanis Despoudis on January 06, 2020

Read the original in CodeThat.today A lot of times when we have upcoming interviews there are cases when you will be asked to do a technical task ...
Collapse
 
jonrandy profile image
Jon Randy 🎖️ • Edited

To reverse a string why not just...

const reverseString = s=>[...s].reverse().join('')
Enter fullscreen mode Exit fullscreen mode
Collapse
 
theodesp profile image
Theofanis Despoudis • Edited

Try not to aggregate the interviewer. They need to see more than one liners. If you wrote that for example I would ask you to implement array.reverse

Collapse
 
jonrandy profile image
Jon Randy 🎖️ • Edited

You stated this was an exercise to warm up specifically for a JS interview.

There are many ways to solve the problem - each demonstrating different areas of knowledge. A good interviewer would appreciate the knowledge and use of modern JS techniques (arrow function, spread operator) - since, after all, it is a JS specific interview.

Why would you ask someone to re-implement array.reverse in a test that is about Javascript? Any implementation you could make is likely to be slower than the built in one. That question would belong in a test about algorithms

Thread Thread
 
theodesp profile image
Theofanis Despoudis • Edited

I would say that any live coding interview questions tend to test you about algorithmic thinking. It's not only about the language. Also, If you can manage to code a dynamic programming task but not a simpler one like array reverse then the interviewer might think something is fishy here.

Thread Thread
 
jonrandy profile image
Jon Randy 🎖️

If that is what they want to test, they should ask for such. As this is framed as a JS interview it would be in the candidate's best interests to highlight their skill in Javascript over general programming ability unless asked otherwise.

If I were interviewing for a JS position, and the candidate's solution proceeded to reinvent the wheel, I would question why they had done it that way. On the basis of that answer I would decide whether or not they're a good fit for a specifically JS position

Thread Thread
 
theodesp profile image
Theofanis Despoudis

It is framed as a Javascript interview but it's not all about Javascript. Javascript may be hot now, but not tomorrow. Algorithms stay longer. That is the mindset.

Unfortunately, not all interviewers are kind to tell you what kinds of tests they will ask you. They could ask you anything. The idea is to be prepared as much as possible.

Collapse
 
alyson profile image
aly quey

Thank you for the post. 🙂

On (2) filter number,
I've just modified as following

console.log(filterNumbers([1, true, 0, "2", null, undefined, "   ", NaN, Number.POSITIVE_INFINITY, 66, "ab1", false]))
// just added true, 0, null, undefined

The output is the following.

[1, 0, "2", null, Infinity, 66]


.

It might be better to add null checking on filtering. :)

    if (isNaN(value) || isBoolean(value) || isEmptyString(value) || value === null) {

-> result [1, 0, "2", Infinity, 66]

I continue reading 3)... 🍣

Thank you.

Collapse
 
theodesp profile image
Theofanis Despoudis

Cool!