---
id: 69162d64f96574d9bb629efe
title: "Challenge 113: Miles to Kilometers"
challengeType: 28
dashedName: challenge-113
---

# --description--

Given a distance in miles as a number, return the equivalent distance in kilometers.

- The input will always be a non-negative number.
- 1 mile equals 1.60934 kilometers.
- Round the result to two decimal places.
- Remove unnecessary trailing zeros from the rounded result.

# --hints--

`convertToKm(1)` should return `1.61`.

```js
assert.equal(convertToKm(1), 1.61);
```

`convertToKm(21)` should return `33.8`.

```js
assert.equal(convertToKm(21), 33.8);
```

`convertToKm(3.5)` should return `5.63`.

```js
assert.equal(convertToKm(3.5), 5.63);
```

`convertToKm(0)` should return `0`.

```js
assert.equal(convertToKm(0), 0);
```

`convertToKm(0.621371)` should return `1`.

```js
assert.equal(convertToKm(0.621371), 1);
```

# --seed--

## --seed-contents--

```js
function convertToKm(miles) {

  return miles;
}
```

# --solutions--

```js
function convertToKm(miles) {
  const km = miles * 1.60934;
  return Math.round(km * 100) / 100;
}
```
