Where do i Belong - code challenge

Hello All,

I am working my way for completing this challenge where I receive a Number and an Array of numbers and it has to return the position of this number in the array.

When i try to run it in Repl.it i receive the “SyntaxError: Unexpected end of input” error message. I am not sure where im getting it wrong, though. Can you help me please?

My code so far is the following:

function getIndexToIns(arr, num) {

let sortArr = arr.sort((a,b) => a-b); // sorts array in crescent order

if (sortArr == []) {return 0} // deals with cases of empty arrays
else if (num >= sortArr[sortArr.length-1]) 
{return sortArr.length} // deals with cases where num is higher than the last number of the array
else { for (let i = 0; i < sortArr.length ; i++) {
 if (num <= sortArr[i]) {return i} 
} // deals with all the other possibilities

console.log(getIndexToIns([10, 20, 30, 40, 50], 35));

Your browser information:

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

Challenge: Where do I Belong

Link to the challenge:

You are missing a closing curly brace at the end of your code.

Indenting things would help you to spot it!