Skip to content

Latest commit

 

History

History
25 lines (18 loc) · 1.96 KB

File metadata and controls

25 lines (18 loc) · 1.96 KB

Contains Duplicate easy #javascript #blind75

by Pawan Kumar @jsartisan

Take the Challenge

Given an array of integers nums, write a function that returns true if any value appears at least twice in the array, and returns false if every element is distinct.

Requirements:

  1. The function should take one argument:
    • An array of integers, nums.
  2. The function should return:
    • true if there is at least one duplicate value.
    • false if all values are unique.

Example Usage:

// Example 1
const nums1 = [1, 2, 3, 3];
console.log(hasDuplicate(nums1)); // Output: true

// Example 2
const nums2 = [1, 2, 3, 4];
console.log(hasDuplicate(nums2)); // Output: false

Back Share your Solutions Check out Solutions