Coding task · JavaScript and TypeScript course · Module 2: Functions, Arrays and Objects
Using the Symbol Type
Every call to Symbol() creates a new, unique value, even with the same description. You write a Symbol as an object key in square brackets: { [sampleId1]: ... }.
Task
Create two DNA sample identifiers: const sampleId1 = Symbol('DNA-001') and const sampleId2 = Symbol('DNA-001'). Display the result of sampleId1 === sampleId2 in the console. Then create an object specimen with the property name: 'T-Rex' and the sample data (e.g. { purity: 98.5 }) stored under the key sampleId1.