2018-10-10 18:03:03 -04:00
---
id: 587d7b84367417b2b2512b35
2021-02-06 04:42:36 +00:00
title: Catch Misspelled Variable and Function Names
2018-10-10 18:03:03 -04:00
challengeType: 1
2020-09-07 16:09:54 +08:00
forumTopicId: 301186
2021-01-13 03:31:00 +01:00
dashedName: catch-misspelled-variable-and-function-names
2018-10-10 18:03:03 -04:00
---
2020-12-16 00:37:30 -07:00
# --description--
2021-02-06 04:42:36 +00:00
The `console.log()` and `typeof` methods are the two primary ways to check intermediate values and types of program output. Now it's time to get into the common forms that bugs take. One syntax-level issue that fast typers can commiserate with is the humble spelling error.
2020-12-16 00:37:30 -07:00
2021-02-06 04:42:36 +00:00
Transposed, missing, or mis-capitalized characters in a variable or function name will have the browser looking for an object that doesn't exist - and complain in the form of a reference error. JavaScript variable and function names are case-sensitive.
2018-10-10 18:03:03 -04:00
2020-12-16 00:37:30 -07:00
# --instructions--
2021-02-06 04:42:36 +00:00
Fix the two spelling errors in the code so the `netWorkingCapital` calculation works.
2020-12-16 00:37:30 -07:00
# --hints--
2018-10-10 18:03:03 -04:00
2021-02-06 04:42:36 +00:00
Check the spelling of the two variables used in the netWorkingCapital calculation, the console output should show that "Net working capital is: 2".
2018-10-10 18:03:03 -04:00
2020-12-16 00:37:30 -07:00
```js
assert(netWorkingCapital === 2);
```
2018-10-10 18:03:03 -04:00
2021-02-06 04:42:36 +00:00
There should be no instances of mis-spelled variables in the code.
2018-10-10 18:03:03 -04:00
```js
2020-12-16 00:37:30 -07:00
assert(!code.match(/recievables/g));
2018-10-10 18:03:03 -04:00
```
2021-02-06 04:42:36 +00:00
The `receivables` variable should be declared and used properly in the code.
2018-10-10 18:03:03 -04:00
2020-12-16 00:37:30 -07:00
```js
assert(code.match(/receivables/g).length == 2);
```
2018-10-10 18:03:03 -04:00
2021-02-06 04:42:36 +00:00
There should be no instances of mis-spelled variables in the code.
2018-10-10 18:03:03 -04:00
2020-12-16 00:37:30 -07:00
```js
assert(!code.match(/payable;/g));
```
2018-10-10 18:03:03 -04:00
2021-02-06 04:42:36 +00:00
The `payables` variable should be declared and used properly in the code.
2018-10-10 18:03:03 -04:00
```js
2020-12-16 00:37:30 -07:00
assert(code.match(/payables/g).length == 2);
2018-10-10 18:03:03 -04:00
```
2020-08-13 17:24:35 +02:00
2021-01-13 03:31:00 +01:00
# --seed--
## --seed-contents--
```js
let receivables = 10;
let payables = 8;
let netWorkingCapital = recievables - payable;
console.log(`Net working capital is: ${netWorkingCapital}` );
```
2020-12-16 00:37:30 -07:00
# --solutions--
2021-01-13 03:31:00 +01:00
```js
let receivables = 10;
let payables = 8;
let netWorkingCapital = receivables - payables;
console.log(`Net working capital is: ${netWorkingCapital}` );
```