+ 1

Experimenting with JS return statement... help [SOLVED]

Is return only used for operations? +, -, /, * Or can you use it for other things too, like what Iā€™m attempting in my code below? Itā€™s very clear what Iā€™m trying to do in the following code. YOUR LIST TO BE RANDOMIZED[Math.floor...] https://code.sololearn.com/WN3noR44IKMV/?ref=app

7th Aug 2020, 8:31 AM
Ginfio
Ginfio - avatar
2 Answers
+ 3
You can put anything in the return statement. The problem is that on line 18, you are multiplying a number by an array Math.floor(Math.random()*list) Here, Math.random() returns a number which you are multiplying with list, an array. Replace `list` with `list.length` and your code should work fine
7th Aug 2020, 8:35 AM
XXX
XXX - avatar
+ 2
XXX OMG. what am i thinking.? I donā€™t know how did I forgot about that. I guess I just needed someone to remind ne. Thank.You()
7th Aug 2020, 8:39 AM
Ginfio
Ginfio - avatar