Does filter do implicit type conversion?

Tell us what’s happening:
In method filter(el=> el.rating>=8.0); how it is comparing string with floating point number ?. In question it was mentioned that you need to convert string to number before conversion so please tell me how this code is working fine

Your code so far

WARNING

The challenge seed code and/or your solution exceeded the maximum length we can port over from the challenge.

You will need to take an additional step here so the code you wrote presents in an easy to read format.

Please copy/paste all the editor code showing in the challenge from where you just linked.

var filteredList;
filteredList= watchList.map(el=>{
  return {title: el["Title"],
  rating:el["imdbRating"]
  }
}).filter(el=>  el.rating>=8.0);
 

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.88 Safari/537.36.

Challenge: Use the filter Method to Extract Data from an Array

Link to the challenge:
https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/functional-programming/use-the-filter-method-to-extract-data-from-an-array

filter do something with the return value of the callback, it doesn’t have magic powers other than that

instead, you need to find out how >= behaves with values of different types

Do you have any link to study about it or blog post ? What should i type on Google ?

something like “type conversion comparison operators”, isn’t that what you want to find out?

1 Like