Help with excercise Distinct values of a set
Hi, I ran can't get right the exercise from Set in ES6. Could you please try to help me to find a mistake in my code? Thanks a lot in advance!!!! Here is the task: You are making a program for a sports store warehouse. The warehouse currently has 7 types of sports equipment and plans to purchase more. The program you are given takes 3 new purchased item types as input. let products = new Set(["dumbbells", "barbell", "t-shirt", "swim short", "gloves", "training apparatus", "goggle"]); NODE Write a program to add the new items to the given set, then calculate and output to the console the count of item types in the warehouse. Sample Input barbell gloves bandage Sample Output 8 Explanation Before the purchase, we already had a "barbell" and "gloves", but did not have a "bandage". So +1 to our item types: 7+1 = 8. Now is the right time to use size property. Here is my solution, which passes only the last test case, but for some reason not all of them. function main() { let products = new Set([ "dumbbells", "barbell", "t-shirt", "swim short", "gloves", "training apparatus", "goggle" ]); var count = 0; while(count<3){ var itemType = readLine(); //add the item to the set count++; let products = new Set() products.add("itemType1").add("itemType2").add("itemType3"); } //calculate and output the count of item types console.log(products.size); }