Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 1. Write a function to format time which accepts time in seconds and return a string with formatted time
- e.g.
- format_time(1)
- //=> "1 second"
- format_time(125)
- //=> "2 minutes, 5 seconds"
- format_time(2100)
- //=> "35 minutes"
- format_time(2115)
- //=> "35 minutes, 15 seconds"
- 2. Write a function which will format price, input is a float number and returns a string with formatted price
- Example:
- format_price(1500.129)
- // => 'Rs 1,500.12'
- format_price(-5)
- // => 'Rs -5.00'
- format_price(1000000.5)
- // => 'Rs 1,000,000.50'
- 3. Write a function to check if a string is a palindrome and returns 'Nes' or 'No'
- e.g.
- is_palindrome("asdsa")
- //=> "Yes"
- is_palindrome("asddsa")
- //=> "Yes"
- is_palindrome("aaadaa")
- //=> "No"
- 4. Write a function to find the first non repeating letter(ignoring the case) in a given string
- e.g.
- first_non_repeating_letter("a")
- //=> "a"
- first_non_repeating_letter("stress")
- //=> "t"
- first_non_repeating_letter("moonmen")
- //=> "e"
- first_non_repeating_letter("stress stress")
- //=> " "
- first_non_repeating_letter("sTreSS")
- //=> "T"
- 5. Write a function to find perfect numbers between 1 to n, for given n
- perfect_numbers(10)
- //=> [6]
- perfect_numbers(29)
- //=> [6,28]
- perfect_numbers(400)
- //=> [6,28]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement