Skip to main content

Command Palette

Search for a command to run...

Search algorithm / map / forEach

Search algorithm / map / forEach

Published
โ€ข1 min readโ€ขView as Markdown
Search algorithm / map / forEach
S

๐Ÿ‘‹ Hi there! I'm Suzie, a developer who began my coding journey in 2023. Iโ€™m passionate about building fast and dynamic web experiences using Next.js, JavaScript, and Tailwind CSS.

๐ŸŒฑ As I grow in tech, I enjoy documenting my learning journey and sharing insights to help others navigate their path.

โœจ Fun fact: When Iโ€™m not coding, you can find me practicing Capoeria ๐Ÿคธ.

Letโ€™s connect, learn, and create together!

CS50

Search algorithm

  1. Linear Search : it is a method for finding an element within a list. it sequentially checks each element of the list until a match is found or the whole list has been searched.
  2. Binary Search : a.k.a half-interval search. it finds the position of a target value within a sorted array. it compares the target value to the middle element of the array.

image.png

Udemy

forEach() vs map()

image.png

both forEach() & map() create loop but I didn't know what the differences are. but today I had a Angela's lecture and got to know what are those! since forEach does not return anything, we need to make an array to push the result in. However, map doesn't need to do so since it automatically returns an array.