---
id: 699f52fac083214b6bf51de6
title: Step 19
challengeType: 1
dashedName: step-19
---

# --description--

In this last step, you will need to add a conditional check for the `exponent` parameter in the `raiseTo` function. 

If the `exponent` argument is provided, the function should return `base` raised to the power of `exponent`. If the `exponent` argument is not provided, it should return `base ** 2`.

With that last step, your type-safe math toolkit is complete!

# --hints--

Your `raiseTo` function should return `base ** exponent` when `exponent` argument is provided.

```js
assert.strictEqual(raiseTo(3, 3), 27);
```

Your `raiseTo` function should return `base ** 2` when `exponent` argument is not provided.

```js
assert.strictEqual(raiseTo(3), 9);
```

# --seed--

## --seed-contents--

```ts
function square(num: number) {
  return num * num;
}

const result = square(5);

console.log(result);

function getAverage(numbers: number[]): number {
  const sum = numbers.reduce((acc, n) => acc + n, 0);
  return sum / numbers.length;
}

const avgResult = getAverage([2, 14, 26, 8]);

console.log(avgResult);

function raiseTo(base: number, exponent?: number): number {
--fcc-editable-region--
  
--fcc-editable-region--
  
  return base ** 2;
}

const raisedResult = raiseTo(3);
console.log(raisedResult);
```

```json
{
  "compilerOptions": {
    "noCheck": true
  }
}
```

# --solutions--

```ts
function square(num: number) {
  return num * num;
}

const result = square(5);

console.log(result);

function getAverage(numbers: number[]): number {
  const sum = numbers.reduce((acc, n) => acc + n, 0);
  return sum / numbers.length;
}

const avgResult = getAverage([2, 14, 26, 8]);

console.log(avgResult);

function raiseTo(base: number, exponent?: number): number {
  if (exponent) {
    return base ** exponent;
  }
  
  return base ** 2;
}

const raisedResult = raiseTo(3);
console.log(raisedResult);
```

```json
{
  "compilerOptions": {
    "noCheck": true
  }
}
```
