Closed siddhantmadhur closed 2 years ago
It's a great idea! Maybe something like words as text e.g "One", "Two", "Three" also can be a great idea. But we have to figure out new names for it.
I'm thinking how we can make this logic more random
Is there any way to accept arrays from the main function itself, rather than pull it from a json file
We can do that in reducer but then whenever someone select number mode it'll recalculate all the numbers
So I updated the code to generate numbers and generated 1290 numbers using it.
let arr = [];
let append = "";
for(let i = 0; i < 100; i++ ) {
const max = Math.round(Math.random()*8); //decides how long the number is going to be
if(max>4){
append = ""; //resets
for(let j = 0; j < max; j++){ // loops max amt of times, checking if the new number is equal to the last number or not so its random
const cursor = Math.round(Math.random() * 9)
if(append.length>0){
if(append.charAt(j-1).match(cursor)){
j = j-1
}else{
append = append + `${cursor}`
}
}else{
append = append + `${cursor}`
}
}
arr.push(append)
}else {
i = i - 1;
}
}
console.log(arr);
This new code made sure that the numbers being generated have no numbers being repeated in a row, for example: 11111 could not be generated but 12121 could
You can merge this now and I'll create a new PR if i think of a more "randomized" logic.
Sorry for late reply I was busy at work. I'll test this tonight and merge it.
Also you should take a look at Javascript crypto API it provides easier way to generate random number
No worries Also sure I'll check it out
I think 1290 numbers are more than enough. Can you reduce it to 300 or something?
Because it is randomizing these numbers at runtime so it can hurt performance
yeah sure
Looks great
It looks like CSS requires some minor refinements for numbers mode but that's work for another day 😄
Idea: A numbers only mode
Implementation: There can be infinitely cleaner methods to create this so it can be completely random but for convenience sake I made a list of 500+ numbers using the following script and put it in a .json
Limitations: The list is limited to only 500 numbers
Future Ideas: Either directly implement the code into the site or create an improved list with more numbers