Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Noobie request #53

Open
saikesava opened this issue Jan 27, 2023 · 1 comment
Open

Noobie request #53

saikesava opened this issue Jan 27, 2023 · 1 comment

Comments

@saikesava
Copy link

Hey I am new to coding and don't really know what i'm doing I needed a wheel of names for my. project that i've been working on how exactly do I use this with raw html and css

@johnberry09
Copy link

johnberry09 commented Jan 28, 2023

Welcome to the exciting world of coding, and I am glad I am responding to your first issue/question ever on github.

For writing code for a wheel of names, or wheel spinner, is not beginner level coding exercise. Also just using html and css you may not be able to do that, you will need Javascript at least.

The spinning a wheel has a lot of historical significance, however, for learning how to code, it is pretty much the same as having an array of names and random number generation.

A very simple example would be:

const names = [];

names.push('Alice');
names.push('Bob');
names.push('John');
names.push('Jane');
names.push('Tyler');

const getRandomName = (namesArray) => {
  // Math.random() gives you a pseudo random floating point number between 0 and 1
  // because max value would be 1 from the random, we can multiple with our desired max value
  // to get a random number between 0 and our max value (max index of the array)
  const randomNumber = Math.random() * (namesArray.length - 1);
  return namesArray[Math.round(randomNumber)];
};

console.log(getRandomName(names));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants