DEV Community

Arun Kumar G
Arun Kumar G

Posted on

JavaScript Challenges - Strings

Q1. Write a function to validate given email has @ or not

    isValidEmail("test@gmail.com") === true
    isValidEmail("testmail.com") === false
Enter fullscreen mode Exit fullscreen mode

Q2. Write a function check weather given email id is gmail or not

    isGmailId("test@gmail.com") === true
    isGmailId("test@yahoo.com") === false
Enter fullscreen mode Exit fullscreen mode

Q3. Write a function to accept firstName and lastName as param and should return fullName

   getFullName("John","Snow") == "John Snow";
Enter fullscreen mode Exit fullscreen mode

Q4. Uppercase the first character

   upperFirst("john") == "John";
Enter fullscreen mode Exit fullscreen mode

Q5. Truncate a given string with a limit

   truncate("What I'd like to tell on this topic is:", 20) = 
   "What I'd like to te…"
   truncate("Hi everyone!", 20) = "Hi everyone!"
Enter fullscreen mode Exit fullscreen mode

Q6. Function to extract currency value from given string

extractCurrencyValue('$120') === 120
Enter fullscreen mode Exit fullscreen mode

Q7. Function mask every A with

    stringMask("Its A sunny weather") === "Its # sunny we#ther";
Enter fullscreen mode Exit fullscreen mode

Q8. Function to Count Decimal Points in a given number?

   getDecimalCount("43.20")  2
   getDecimalCount("400")  0
   getDecimalCount("3.1")  1
Enter fullscreen mode Exit fullscreen mode

Top comments (0)