-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbackground.js
38 lines (37 loc) · 1.2 KB
/
background.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// challenges.js
const challenges = [
{
text: "Write a function to reverse a string.",
difficulty: "Easy",
hint: "Think about splitting and joining the string."
},
{
text: "Implement a function to check if a number is prime.",
difficulty: "Medium",
hint: "A number is prime if it's only divisible by 1 and itself."
},
{
text: "Create a function that returns the Fibonacci sequence up to a given number.",
difficulty: "Medium",
hint: "Use recursion or a loop to add the last two numbers."
},
{
text: "Write a function to check if a string is a palindrome.",
difficulty: "Easy",
hint: "A palindrome reads the same backward and forward."
},
{
text: "Build a function to find the maximum value in an array.",
difficulty: "Easy",
hint: "You could use a loop or JavaScript's Math.max method."
},
{
text: "Create a function that sorts an array without using built-in methods.",
difficulty: "Hard",
hint: "Try the bubble sort or quicksort algorithm."
},
];
function getRandomChallenge() {
const randomIndex = Math.floor(Math.random() * challenges.length);
return challenges[randomIndex];
}