Object has no method 'indexOf'

indexof, javascript

Solution

Just do a javascript `parseInt(63.00425720214844)` to get 63.

Problem

I have the following function (taken from Elevation Service @ Google Maps API) which output for example `63.00425720214844` when I click somewhere on the map I have created with Google Maps JavaScript API v3: ``` function getElevation(event) { var locations = []; var clickedLocation = event.latLng; locations.push(clickedLocation); var positionalRequest = { 'locations': locations } elevator.getElevationForLocations(positionalRequest, function(results, status) { if(status == google.maps.ElevationStatus.OK) { var s = results[0].elevation if(results[0]) { alert(s.substring(0, s.indexOf('.') - 1)); } else { alert('Inget resultat hittades'); } } else { alert('Det gick inte att hitta höjdskillnaden på grund av följande: ' + status); } }); } ``` I want to remove everything after the dot including the dot, for example remove `.00425720214844` from `63.00425720214844` but when I click somewhere on the map, I'm getting this error message in the console: `Uncaught TypeError: Object 63.00425720214844 has no method 'indexOf'`. What have I done wrong? Thanks in advance.

Original source