-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d0aa6fa
commit 4f3ca44
Showing
9 changed files
with
153 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,58 @@ | ||
// a list of javascript keywords | ||
// different types of javascript keywords | ||
|
||
let keywords = [ | ||
"let", | ||
"break", | ||
"case", | ||
"catch", | ||
"continue", | ||
"debugger", | ||
"default", | ||
"delete", | ||
"do", | ||
"else", | ||
"finally", | ||
"for", | ||
"function", | ||
"if", | ||
"in", | ||
"instanceof", | ||
"new", | ||
"return", | ||
"switch", | ||
"this", | ||
"throw", | ||
"try", | ||
"typeof", | ||
"let", | ||
"while", | ||
"class", | ||
"const", | ||
"enum", | ||
"export", | ||
"extends", | ||
"import", | ||
"super", | ||
"static", | ||
"yield", | ||
"null", | ||
"true", | ||
"false", | ||
"undefined", | ||
"boolean", | ||
]; | ||
let keywords = { | ||
"Vanilla Js": [ | ||
"let", | ||
"break", | ||
"case", | ||
"catch", | ||
"continue", | ||
"debugger", | ||
"default", | ||
"delete", | ||
"do", | ||
"else", | ||
"finally", | ||
"for", | ||
"function", | ||
"if", | ||
"in", | ||
"instanceof", | ||
"new", | ||
"return", | ||
"switch", | ||
"this", | ||
"throw", | ||
"try", | ||
"typeof", | ||
"let", | ||
"while", | ||
"class", | ||
"const", | ||
"enum", | ||
"export", | ||
"extends", | ||
"import", | ||
"super", | ||
"static", | ||
"yield", | ||
"null", | ||
"true", | ||
"false", | ||
"undefined", | ||
"boolean", | ||
], | ||
}; | ||
|
||
// generate a random array of keywords from the above array | ||
let randomKeywords = []; | ||
const generateKeywords = (mode = "Vanilla Js") => { | ||
// generate a random array of keywords from the array of mode type | ||
let randomKeywords = []; | ||
|
||
for (let i = 0; i < 100; i++) { | ||
let randomIndex = Math.floor(Math.random() * keywords.length); | ||
randomKeywords.push(keywords[randomIndex]); | ||
} | ||
for (let i = 0; i < 100; i++) { | ||
let randomIndex = Math.floor(Math.random() * keywords[mode].length); | ||
randomKeywords.push(keywords[mode][randomIndex]); | ||
} | ||
return randomKeywords; | ||
}; | ||
|
||
export default randomKeywords; | ||
export default generateKeywords; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import React from "react"; | ||
|
||
const Char = ({ children, isCorrect = false }) => { | ||
return <span style={{ color: isCorrect ? "#fff" : "#333" }}>{children}</span>; | ||
}; | ||
|
||
export default Char; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import React from "react"; | ||
import { v4 as uuidv4 } from "uuid"; | ||
import Char from "./Char"; | ||
|
||
const Characters = ({ characters }) => { | ||
return ( | ||
<> | ||
{characters.map((i) => ( | ||
<Char key={uuidv4()} isCorrect={i.isCorrect}> | ||
{i.key} | ||
</Char> | ||
))} | ||
</> | ||
); | ||
}; | ||
|
||
export default Characters; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters