Skip to main content

Command Palette

Search for a command to run...

Array Week Challenge - Day 3

An oldie but goodie

Updated
2 min read
Array Week Challenge - Day 3
B

I'm a Senior UI Developer at a global tech consultancy, working on crafting custom solutions for our client companies. Clients range from nascent start-ups to Fortune 10 companies.

I also volunteer as the Community Manager for the community-based FREE online educational program at 100Devs. Its mission is to provide a completely free, accessible, welcoming path to a career as a software engineer.

Current interests include Design Systems, Component Libraries, and teaching beginners.

Heyyyyyy! It's the start of a work week but we're already 3 days into our challenge week. Let's do this!

⏰ You can Catch Up in no time!

We're on day 3 of this week's challenges which build upon each other.

Feel free to catch up:

and then head back over here!

I've also added all of this month's challenges to a series here on my blog - hope that helps!

⭐ Array Week

This week our challenges all deal with Arrays! Their purpose is to store a collection of things under a single reference name, but the way they are set up and used in JavaScript is a little different from other programming languages. If you're coming from a different language, be sure to check out what's different! While working on our challenges, feel free to use JavaScript's built-in Array methods.

🏆 The Challenge - Day 3

This week we'll be working with arrays toward a final puzzling result on Friday when we combine our daily functions. Your solutions should be built to work within any given daily constraints.

Today's challenge is a bit of a tangent, but I think it's pretty powerful. It's inspired by my favorite Codewars kata ever, Moving Zeros To The End. This is my favorite kata because the first time I did it, my approach was so convoluted compared to the top-voted solution, which was a thing of beautiful simplicity. I think the moment I saw that solution something clicked for me and I realized the power of the built-in Javascript methods.

Today I'd like you to write a function that:

  • takes in a given array of strings and move any entries containing the letter 'a' to the front
  • then move any remaining entries that have over 3 characters to the back
  • please preserve the relative order of entries within their given category

Example:

myArr = ['hi', 'hello', 'howdy', 'hola', 'hej', 'hallo', 'heyyy']
// move things around
=> ['hola', 'hallo', 'hi', 'hej', 'hello', 'howdy', 'heyyy']

Have fun!


Wait, What's Huntober?

Leon Noel's 100Devs are spending October preparing for the job hunt. Anyone who has already broken into a tech career knows that the application and interview process can be grueling! The current cohort has progressed this year all the way from basic HTML files to hosted full-stack applications with authentication and databases.

This month they'll continue to build, but will also work on data structures & algorithms, networking and interview skills, and solving code challenges.

E

I love those challenges! They are so addictive! I just have one question though... Is there a way to check other answers? We can learn so much by seeing different approaches to the same problem. Especially when we're unsure if there was a more efficient way to get the same result. Thank you so much for putting the time and effort to do this Blaw! You rock!

1
B
Barbara3y ago

I would love people to share their solutions with each other! Let me think about a good way to encourage this and somewhere easy to do it. Thanks for that thought!

J

Thanks for the extra insight. Just given the problem I'm sure I would have just looped with some ifs and called it a day. Really got me thinking about the best methods to use.

1
S
Shah3y ago

This was fun!

1
A

Great one thanks a lot.🙏 and thank you for the codewars one it's a really nice one to increase the honors points 😁.

1

Huntober 2022 - Daily Coding Challenges

Part 4 of 13

My daily coding challenges for Huntober 2022. Each week has a topic focus and the daily challenges build upon each other toward a final week-end result!

Up next

Array Week Challenge - Day 2

Rearranging a few things