Skip to content

Commit

Permalink
Merge pull request loverajoel#279 from boneskull/issue/42
Browse files Browse the repository at this point in the history
Modify tip to avoid throwing; closes loverajoel#42
  • Loading branch information
zenopopovici committed Mar 1, 2016
2 parents 8ef67fc + a50aed8 commit 5e953b1
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ You just have to concat everything into an array first. `Array.concat` will acce

```javascript
function printUpperCase(words) {
var elements = [].concat(words);
var elements = [].concat(words || []);
for (var i = 0; i < elements.length; i++) {
console.log(elements[i].toUpperCase());
}
}
```

`printUpperCase` is now ready to accept a single node or an array of nodes as its parameter.
`printUpperCase` is now ready to accept a single node or an array of nodes as its parameter. It also avoids the potential `TypeError` that would be thrown if no parameter was passed.

```javascript
printUpperCase("cactus");
Expand Down

0 comments on commit 5e953b1

Please sign in to comment.