Write a function Value
returning an object, which purpose is to store a numeric value. The value of the object will be mutable, but also protected with min and max. This should be achieved through getters and setters.
Example usage:
v = Value();
v.value
//=> 0
v2 = Value({value: 10, min: 0, max: 100});
v2.value = 101
//=> Error: Out of bounds
The implementation should pass all tests defined in tests.js. To run tests:
runTests(tests);
Hey there.
Interested to know how you get all tests to pass with this. I can get all but the number context one working here.
I haven't used the Object.defineProperty and Object.create stuff too much before but I was assuming there was some simple thing I was overlooking or maybe I am creating my object in a slightly different way.
Either way, it's interesting to learn another approach. I hadn't really gone down the get set path much with components I've written so far so this stuff is very useful to know as another approach.
Thanks
@jheytompkins