Javascript - Challenge
Code Life
By Pierre Marsaa
Private Codédex
Build a Codédex whose entries cannot be modified from outside. Only the functions you provide may touch the list.
Step 1: makeCodedex() keeps a hidden array entries and returns an object with three methods.
Step 2: add(name) adds the name only if it isn't there yet, printing "Added X", otherwise it prints "Already known: X".
Step 3: count() returns how many entries there are, and list() returns the names joined with ", ".
Step 4: add Zap, Aquachu, then Zap again. Print the count, the list, and the result of reading entries directly on the object.
Expected output:
Loading editor...
↗️
Loading editor...
↶
↷
💡 Show Solution
Continue