Tell us what’s happening:
Need help with objectFreeze In this challenge you are going to use Object.freeze
to prevent mathematical constants from changing. You need to freeze the MATH_CONSTANTS
object so that no one is able to alter the value of PI
, add, or delete properties.
Your code so far
function freezeObj() {
‘use strict’;
const MATH_CONSTANTS = {
PI: 3.14
};
// Only change code below this line
object.freeze(MATH_CONSTANTS);
// Only change code above this line
try {
MATH_CONSTANTS.PI = 99;
} catch(ex) {
console.log(ex);
}
return MATH_CONSTANTS.PI;
}
const PI = freezeObj();
<body>
<script>
// Add your code below this line
d3.select("ul")
.append("li")
h1
.text('LearningD3')
// Add your code above this line
</script>
</body>
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.88 Safari/537.36
.
Challenge: Add Document Elements with D3
Link to the challenge: