May 8, 2021
Choosing a Random Letter – JavaScript Idea Series
Comments
(9)
May 8, 2021
Choosing a Random Letter – JavaScript Idea Series
I am currently a provider of technical training and support in the electronic manufacturing industry. My prior training and work experience as a teacher, network administrator, web design, and instructional design make me well prepared to design it, develop it, and deliver it. I am a father of five, a US Army veteran, and I enjoy playing the guitar as well as performing in local community theater. 
Legend 99 posts
Followers: 155 people
(9)

You may have wondered about or even implemented the idea of random numbers but have you ever thought about selecting a random letter?

Here is one way of making this work. I would love to hear about some ways you might be able to use random letters in your projects. Please share them in the comments. Feel free to share any questions that you may have.

A working sample with code is below.

Preview Project

<—— JavaScript Idea Series

 

9 Comments
2021-05-10 13:36:57
2021-05-10 13:36:57

Used a similar approach but not for letters, when choosing a random image (from a multistate object).

You can also limit the number of letters to those of a particular word to present them in a shuffled sequence for a game where that words needs to be composed (by D&D).

Like
(1)
(2)
>
Lieve Weymeis
's comment
2021-05-10 13:52:55
2021-05-10 13:52:55
>
Lieve Weymeis
's comment

Randomization opens up a world of possibilities.

Concatenation with variables and multistate objects is one strategy.

Another strategy I plan to demonstrate related to randomization is using arrays – which are great for many sorts of word games. I used arrays in the realization of the Hangman and Animal Spelling projects.

Like
()
>
Greg Stager
's comment
2021-05-10 13:58:33
2021-05-10 13:58:33
>
Greg Stager
's comment

I gave up pleading to have concatenation in the Advanced Actions dialog box, because that would create lot of new possibilities and simplify many actions.

As you know I prefer shared/advanced actions, but use JS for three goals: randomization (of course), formatting of numbers/dates and arrays.  Randomization is the number 1 without any doubt.

Like
()
2021-05-10 12:29:48
2021-05-10 12:29:48

Hello and thank you (again) Greg !…

Here is my contribution :

In France, we used to play a game when I was a child which was called “le baccalauréat“…

It was a game of vocabulary… We have to pick up a letter (For this purpose we used to open a dictionary on a random page and select the corresponding letter !) and complete a table with categories like “animal”, “geography”, “names”, “jobs”, “plants”… and whatever you want. The first letter of each words must be the selected letter.

Of course we could elaborate on such a game with your idea of randomly select a letter !…

😉

Like
(1)
(5)
>
Ludovic Mercier
's comment
2021-05-10 13:31:44
2021-05-10 13:31:44
>
Ludovic Mercier
's comment

Sounds like a great use for this concept!

Perhaps you could see such a project come to fruition.

Like
(1)
>
Greg Stager
's comment
2021-05-11 11:37:36
2021-05-11 11:37:36
>
Greg Stager
's comment

Done !…

A first try… But already happy with it !…

http://soutien67.fr/francais/activites/vocabulaire/Baccalaureat_01/index.html

Thanks again so !…

😉

Like
(1)
>
Ludovic Mercier
's comment
2021-05-11 11:52:21
2021-05-11 11:52:21
>
Ludovic Mercier
's comment

Awesome! Glad it was something you were able to put to use.

It also looks like you used the same strategy to randomly choose the category and number of responses. That can extend to endless possibilities.

Nice work!

Like
(1)
>
Ludovic Mercier
's comment
2021-12-30 00:38:36
2021-12-30 00:38:36
>
Ludovic Mercier
's comment

Hello! Hoping you guys can help me figure out what I have done wrong. I created a variable named “num” the type is number.

The trigger – Execute JavaScript JavaScript when the user clicks button

JavaScript:

var num = Math.floor(Math.random() * 26) + 1;
cp.changeState(“letterBox”,”letter”+num);

Rhoda

Like
()
>
RhodaGreen
's comment
2022-01-04 12:41:05
2022-01-04 12:41:05
>
RhodaGreen
's comment

Just got a notification about this post a few hours ago but it says 5 days ago here…?

Anyway – sorry if it has actually been that long.

This idea depends on having a series of states for an object named  letterBox
where all of the state names follow the same pattern  letter1,  letter2,  letter3,  etc

These names are case sensitive. Can you verify that you have an object named letterBox with 26 additional states named  letter1 thru letter26?

Like
()
Add Comment