give me 5 not to easy JS problems
- User
give me 5 not to easy JS problems
- Assistant
Here are five relatively challenging JavaScript problems for you:
-
Reverse words in a string: Write a function that takes a string as input and returns the string with the words reversed. For example, given the input "Hello World", the function should return "olleH dlroW".
-
Fibonacci sequence: Write a function that generates the Fibonacci sequence up to a given number. The function should take an integer as input and return an array with the Fibonacci numbers (starting from 0). For example, given the input 8, the function should return [0, 1, 1, 2, 3, 5, 8].
-
Anagram detection: Write a function that takes in two strings and determines whether they are anagrams of each other. Anagrams are words or phrases formed by rearranging the letters of another word or phrase. For example, given the inputs "listen" and "silent", the function should return true.
-