---
id: 6a2037a68a0bc2aef0006006
title: "Challenge 344: Golden Ratio"
challengeType: 28
dashedName: challenge-344
---

# --description--

Given two numbers, determine if their ratio approximates the golden ratio.

- Use a golden ratio of `1.618`
- Allow a tolerance of `0.01`

# --hints--

`isGoldenRatio(21, 34)` should return `true`.

```js
assert.isTrue(isGoldenRatio(21, 34));
```

`isGoldenRatio(15, 20)` should return `false`.

```js
assert.isFalse(isGoldenRatio(15, 20));
```

`isGoldenRatio(8, 13)` should return `true`.

```js
assert.isTrue(isGoldenRatio(8, 13));
```

`isGoldenRatio(10, 16)` should return `false`.

```js
assert.isFalse(isGoldenRatio(10, 16));
```

`isGoldenRatio(1618, 1000)` should return `true`.

```js
assert.isTrue(isGoldenRatio(1618, 1000));
```

`isGoldenRatio(88, 55)` should return `false`.

```js
assert.isFalse(isGoldenRatio(88, 55));
```

# --seed--

## --seed-contents--

```js
function isGoldenRatio(a, b) {

  return a;
}
```

# --solutions--

```js
function isGoldenRatio(a, b) {
  const goldenRatio = 1.618;
  const ratio = Math.max(a, b) / Math.min(a, b);
  return Math.abs(ratio - goldenRatio) <= 0.01;
}
```
