DEV Community

DPC
DPC

Posted on

3 5 5 5 4

Daily JavaScript Challenge #JS-178: Find the Longest Common Prefix

Daily JavaScript Challenge: Find the Longest Common Prefix

Hey fellow developers! 👋 Welcome to today's JavaScript coding challenge. Let's keep those programming skills sharp!

The Challenge

Difficulty: Medium

Topic: String Manipulation

Description

Write a function that finds the longest common prefix string amongst an array of strings. If there is no common prefix, return an empty string "".

Ready to Begin?

https://www.dpcdev.com/

  1. Fork this challenge
  2. Write your solution
  3. Test it against the provided test cases
  4. Share your approach in the comments below!

Want to Learn More?

Check out the documentation about this topic here: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Working_with_Strings

Join the Discussion!

  • How did you approach this problem?
  • Did you find any interesting edge cases?
  • What was your biggest learning from this challenge?

Let's learn together! Drop your thoughts and questions in the comments below. 👇


This is part of our Daily JavaScript Challenge series. Follow me for daily programming challenges and let's grow together! 🚀

javascript #programming #coding #dailycodingchallenge #webdev

Heroku

Deploy with ease. Manage efficiently. Scale faster.

Leave the infrastructure headaches to us, while you focus on pushing boundaries, realizing your vision, and making a lasting impression on your users.

Get Started

Top comments (3)

Collapse
 
nathan_tarbert profile image
Nathan Tarbert •

Growth from these kinds of challenges sneaks up on me - every day it gets a bit easier to spot the patterns

Collapse
 
dotallio profile image
Dotallio •

Funny how often I've seen this one pop up in interviews! I find sorting the array can actually make prefix extraction way easier. Did anyone hit any weird edge cases with empty or single-item arrays?

Collapse
 
dpc profile image
DPC •

Maybe we can add an 'interview questions' / 'interview challenges' section? 🤔