Panic Function in JavaScript

JS challenge I solved today, Alhamdulillah: The Problem Write a panic() function that: i. Converts a sentence to uppercase ii. Adds ! at the end iii. Inserts a separator between words if it has more than one word My Thought Process I planned to: Split the string into words using split() Check if it has one word or multiple Use a normal space for single-word input Use a custom separator for multi-word input Then uppercase everything and add '!' The Mistake I initially made the logic more complex than necessary. The only thing that really changes is the separator. Clean Solution although different from the solution given by the teacher: What Clicked: Many problems feel big until you isolate the one part that actually changes. #javascript #frontend #learninginpublic #codingjourney

  • text

To view or add a comment, sign in

Explore content categories