Answered step by step
Verified Expert Solution
Question
1 Approved Answer
USE JAVASCRIPT (HASH MAPS) You are given a list of products whose data is seperated into three different arrays that holds the name, price, and
USE JAVASCRIPT (HASH MAPS) You are given a list of products whose data is seperated into three different arrays that holds the name, price, and weight of the product respectively. Consider the following arrays for example: name = ["ball", "bat", "glove", "glove", "glove"] price = [2, 3, 1, 2, 1] weight - (2, 5, 1, 1, 1] Our first product is a ball with price of 2 and a weight of 2. The second product is a bat with a price of 3 and a weight of 5. Our third product is a glove with a price of 1 and a weight of 1. Our fourth product is a glove with a price of 2 and a weight of 1. **Duplicate products contain identical parameters for all fields in the list (i.e. name, price, and weight). ** Write a function "hasDuplicates() that returns true if there is a duplicate product, and returns false if every product is unique. Your solution should have **linear runtime complexity.** const hasDuplicates = (name, price, weight) => [
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started