Skip to content

Commit

Permalink
fix(curriculum): Added 9 missing solutions to challenges in the Debug…
Browse files Browse the repository at this point in the history
…ging section (#35750)

* fix: add 9 solutions to challenges

* fix: remove extra line

Co-Authored-By: RandellDawson <5313213+RandellDawson@users.noreply.github.com>
  • Loading branch information
RandellDawson authored and thecodingaviator committed Apr 18, 2019
1 parent 7aceb45 commit 54bc113
Show file tree
Hide file tree
Showing 9 changed files with 71 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,13 @@ console.log(power);
<section id='solution'>

```js
// solution required
function raiseToPower(b, e) {
return Math.pow(b, e);
}

let base = 2;
let exp = 3;
let power = raiseToPower(base, exp);
console.log(power);
```
</section>
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,13 @@ console.log(result);
<section id='solution'>

```js
// solution required
function getNine() {
let x = 6;
let y = 3;
return x + y;
}

let result = getNine();
console.log(result);
```
</section>
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ console.log(`Net working capital is: ${netWorkingCapital}`);
<section id='solution'>

```js
// solution required
let receivables = 10;
let payables = 8;
let netWorkingCapital = receivables - payables;
console.log(`Net working capital is: ${netWorkingCapital}`);
```
</section>
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ console.log(innerHtml);
<section id='solution'>

```js
// solution required
let innerHtml = "<p>Click here to <a href=\"#Home\">return home</a></p>";
console.log(innerHtml);
```
</section>
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,16 @@ countToFive();
<section id='solution'>

```js
// solution required
function countToFive() {
let firstFive = "12345";
let len = firstFive.length;
// Fix the line below
for (let i = 0; i < len; i++) {
// Do not alter code below this line
console.log(firstFive[i]);
}
}

countToFive();
```
</section>
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ console.log(`Sum of array values is: ${arraySum}`);
<section id='solution'>
```js
// solution required
let myArray = [1, 2, 3];
let arraySum = myArray.reduce((previous, current) => previous + current);
console.log(`Sum of array values is: ${arraySum}`);
```
</section>
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,16 @@ console.log(result);
<section id='solution'>

```js
// solution required
let x = 7;
let y = 9;
let result = "to come";

if(x === y) {
result = "Equal!";
} else {
result = "Not equal!";
}

console.log(result);
```
</section>
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ function myFunc() {
<section id='solution'>

```js
// solution required
function myFunc() {
for (let i = 1; i <= 4; i += 2) {
console.log("Still going!");
}
}
```
</section>
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,24 @@ console.log(matrix);
<section id='solution'>

```js
// solution required
function zeroArray(m, n) {
// Creates a 2-D array with m rows and n columns of zeroes
let newArray = [];
for (let i = 0; i < m; i++) {
let row = [];
// Adds the m-th row into newArray

for (let j = 0; j < n; j++) {
// Pushes n zeroes into the current row to create the columns
row.push(0);
}
// Pushes the current row, which now has n zeroes in it, to the array
newArray.push(row);
}
return newArray;
}

let matrix = zeroArray(3, 2);
console.log(matrix);
```
</section>

0 comments on commit 54bc113

Please sign in to comment.