Monday and Tuesday
JavaScript
20 pts
Monday and Tuesday
Two Sets list who came to the coding club on Monday and on Tuesday. Write two functions that take two Sets and return a new Set:
common(a, b): the values that are in bothaandb.onlyIn(a, b): the values inathat are not inb.
Use Array.from(), filter() and has() (not the new 2024 methods). Expected output:
Set(2) { "Abel", "Ruta" }
Set(2) { "Selam", "Senait" }
Set(2) { "Yonas", "Merhawi" }
Checklist
- Keep both functions.
common(a, b)returns a new Set of the values in both.onlyIn(a, b)returns a new Set of the values only ina.- Use
filter()andhas(). - Print the three results.
🔑 Solution
If you view the solution before passing, you earn half points for this exercise. You still need to type it and press Check to finish.
How it works, step by step
Point at a step to highlight its lines. Type the solution yourself and press Check answer to finish.
