I went on an interview and I was asked a question like the one in the codepen. I was asked to fix it as its broken. Just curious how others would answer this one
For further actions, you may consider blocking this person and/or reporting abuse
I went on an interview and I was asked a question like the one in the codepen. I was asked to fix it as its broken. Just curious how others would answer this one
For further actions, you may consider blocking this person and/or reporting abuse
Emil Pearce -
Dimitris Stoikidis -
Muchhal Sagar -
Mitchell -
Top comments (4)
Change:
if ($element.filter('.js-cool, .js-beans')) {
to
if ($element.filter('.js-cool, .js-beans').length) {
.filter
returns an Array, which inherits from Object, and all Objects are truthy in JavaScript.That is a good way to solve this
We can use a check to see what values the input has at keyboard events. Then if it has empty string we can simply restore the original
font-size
of the mentioned classes.Here is an approach to do so:
Why looping over all objects and filter out then when you can start with a beter filter.