Is the item in the array past the halfway point?

Is the item in the array past the halfway point?
0.0 0

#1

“// return true if the passed item is in the second half of the array and false otherwise (not including the item in the middle of an array with odd length)”

Had an issue with this but realised that it was for odd length arrays.
I needed to round the half-way point up using Math.ceil().

so instead if array was [1,2,3] it would return true for 2 because length without rounding up would be 1.5.

Gonna leave it though incase someone else has a similar problem

Made a formula that seems to work for the above, but It isnt passing when I run it



function isItemPastHalf (array, item) {
  var lengthOfArray = array.length
  console.log(lengthOfArray)
  var locationOfItem = array.indexOf(item)+1
  console.log(indexofItem)
  
  
  
 

  if(locationOfItem>(lengthOfArray/2))
  {
    return true
  }
  else
  {
    return false

  }
 

  
}






this is what its being tested against

//should be true//

array = [1, 2, 3];
isItemPastHalf(array, 3)

does return true

//should be true//
array = [1, 2, 3, 4];
isItemPastHalf(array, 3)

does return true

//should be false//
array = [1, 2, 3];
isItemPastHalf(array, 2)

doesnt return false
//should be false//

edit: Ok I realise here what was up i wasnt rounding up the halfway point integer

i fixed this by adding


 var halfWayInteger  = Math.ceil(lengthOfArray/2)
  
  
 

  if(locationOfItem>halfWayInteger)
  {
    return true
  }
  else
  {
    return false

  }