gpt-3.5-turbo-0301· OpenAI
WildChat-4.8M (AI2)
Write 10 simple beginner JavaScript exercises/problems. Must be not math-heavy.
- User
Write 10 simple beginner JavaScript exercises/problems. Must be not math-heavy.
- Assistant
- Write a function that takes a string as input and returns the reverse of the string.
- Write a program that checks if a number is even or odd.
- Write a function that takes in an array of numbers and returns the sum of all the numbers in the array.
- Write a program that prompts the user to enter their name and then displays a greeting using their name.
- Write a function that takes in a string and returns the number of vowels in the string.
- Write a program that prompts the user to enter a number and then displays all the even numbers from 0 up to that number.
- Write a function that takes in an array of numbers and returns the largest number in the array.
- Write a program that prompts the user to enter two numbers and then displays the sum, difference, product, and quotient of those numbers.
- Write a function that takes in a string and removes all the whitespace from the string.
- Write a program that prompts the user to enter a number and then displays that number's times table up to 10.
- User
Make them slightly harder
- Assistant
- Write a function that takes a sentence as input and returns a new sentence with all words in reverse order. Example: "The quick brown fox" -> "fox brown quick The".
- Write a program that prompts the user to enter a series of numbers separated by commas and then outputs the average of those numbers.
- Write a function that takes in a string and returns the number of words in the string.
- Write a program that prompts the user to enter a number and then displays all the prime numbers up to that number.
- Write a function that takes in an array of strings and returns a new array with all the strings sorted alphabetically.
- Write a program that prompts the user to enter a series of words separated by commas and then outputs the longest word.
- Write a function that takes in an array of numbers and returns an array of the numbers sorted in descending order.
- Write a program that prompts the user to enter a series of numbers separated by commas and then outputs the numbers in ascending order without duplicates.
- Write a function that takes in two numbers and returns their greatest common divisor using the Euclidean algorithm.