I have the following code in Ruby. I want to convert this code into JavaScript. What is the equivalent code in