100 JS Functions

Beginner

1. minutesToHours

2. averageOf4Numbers

3. concat3

4. max5

5. getMonthsNeededToWait

6. getGasolineAmount

7. lastNRevert

8. getBusinessAddress

9. getUserObject

10. canDriveCar

11. areAllNumbersEven

12. getBiggestNumberInArrays

13. getLongestString

14. everyNPositions

15. doubleNumbers

16. mostRepetitions

17. getMillisecondsBetween

18. getMonthOfTheYear

19. addDays

20. getDevelopers

21. extractElementsBetweenPositions

22. isSorted

23. halfAndHalf

24. isSameDay

25. getMaxMovingDistance

Intermediate

26. arrayToObject

27. pickFields

28. getHighestPaidEmployee

29. flipObject

30. diffArrays

31. countPageViews

32. linkedNumbersSum

33. getMissingContacts

34. removeFirstAndLast

35. biggestPowerOf2

36. areValuesUnique

37. fetchGitHubName

38. rotateArray

39. getDaysInMonth

40. formatDateTime

41. toDecimal

42. compareSets

43. groupBirthdays

44. diffReactions

45. rgbToHex

46. timeAgo

47. customArraySort

48. moveItems

49. isValidPassword

50. mergeSortedArrays

51. ascendingSplit

52. findUniqueNumber

53. parseQueryParams

54. simpleCompression

55. partitionArray

56. findFreeCalendarSpots

57. mergeIntervals

58. simpleURLParser

59. pickNested

60. fetchNamesOfAllPublicRepos

61. getPaginatedData

62. getCheckPassword

63. getAdd5

64. getAddN

65. fetchClosedPullRequests

66. fetchBranchNames

67. searchMessages

68. objectToMap

69. createQueue

70. createStack

71. isSameWeek

72. bfsTraversal

73. dfsTraversal

74. getDoubleN

75. deepCopy

Advanced

76. uniqBy

77. flow

78. createCounter

79. createPromise

80. reverseForEach

81. checkSettlesInTime

82. sorted

83. groupBy

84. createLinkedList

85. promiseOrder

86. isDeepEqual

87. delayResolve

88. classInheritance

89. customBind

90. todoList

91. reverseReduce

92. withCount

93. maxInvocations

94. createObservable

95. createPubSub

96. cacheGetResult

97. currySum

98. getCurry

99. throttle

100. debounce

42.compareSets

Write a function named compareSets that receives 2 parameters.

  • a Set of numbers - setA
  • a Set of numbers - setB

The function should compare the 2 sets and return an Object with the following properties:

  • onlyA - a Set with all elements inside setA that are not part of setB
  • onlyB - a Set with all elements inside setB that are not part of setA
  • union - a Set with all elements inside setA and setB

Example 1

Input

setA

=

setB

=

Output

You'll see test results here!