Solution prevent-object-mutation.english.md (#18767)

* Update prevent-object-mutation.english.md

* Improved JavaScript style
pull/19395/head
Prabhat Kumar Sahu 2018-10-16 05:34:52 +05:30 committed by Todd Chaffee
parent 9354cac5e6
commit 9f98cdce3b
1 changed files with 18 additions and 2 deletions

View File

@ -41,7 +41,7 @@ tests:
```js
function freezeObj() {
"use strict";
'use strict';
const MATH_CONSTANTS = {
PI: 3.14
};
@ -69,6 +69,22 @@ const PI = freezeObj();
<section id='solution'>
```js
// solution required
function freezeObj() {
'use strict';
const MATH_CONSTANTS = {
PI: 3.14
};
// change code below this line
Object.freeze(MATH_CONSTANTS);
// change code above this line
try {
MATH_CONSTANTS.PI = 99;
} catch( ex ) {
console.log(ex);
}
return MATH_CONSTANTS.PI;
}
const PI = freezeObj();
```
</section>