Skip to content

Commit 5555516

Browse files
authored
Fixing function output and also fn argument typo
Found the following two issues in Q13 of functions-concepts. - argument name was num but sum used num1 + num2. In `strict mode` num1 will not be found ( leading to reference error ) and in non strict mode it will be undefined - The string argument which is being passed to console.log is being ignored erroneously. Hence moved the string param to end with its default value and modified the output as well.
1 parent b7c66d1 commit 5555516

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

challenges/functions-concepts.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -381,16 +381,16 @@ Array and object are used in the programs to contain multiple values
381381
- Default function parameters allow named parameters to be initialized with default values if no value or undefined is passed
382382

383383
```js
384-
function defaultValueFunc(num = 10, num2 = 20, string = "Hello", bool = false, sum = num1 + num2 ){
384+
function defaultValueFunc(num = 10, num2 = 20, bool = false, sum = num + num2, string = "Hello"){
385385
console.log(num, string, bool, sum);
386386
}
387387

388388
// driver code
389-
defaultValueFunc(); // 10, 20, false, 30
390-
defaultValueFunc(4, 8); // 4, 8, false, 12
391-
defaultValueFunc(10, 4, true); // 10, 4, true, 14
392-
defaultValueFunc(5, 6, false, 11); // 5, 6, false, 11
393-
defaultValueFunc(undefined, undefined, false); // 10, 20, false, 30
389+
defaultValueFunc(); // 10, 'Hello', false, 30
390+
defaultValueFunc(4, 8); // 4, 'Hello', false, 12
391+
defaultValueFunc(10, 4, true); // 10, 'Hello', true, 14
392+
defaultValueFunc(5, 6, false, 11); // 5, 'Hello', false, 11
393+
defaultValueFunc(undefined, undefined, false); // 10, 'Hello', false, 30
394394
```
395395

396396
###### Notes

0 commit comments

Comments
 (0)