+ 1

Random word

How do I create a random word in the middle of the sentence in JavaScript?

5th May 2020, 9:27 AM
Unrealistic Engineer
Unrealistic Engineer - avatar
9 Respuestas
+ 1
Can you show an example of what you are talking ? You can use Math.Random() it returns 0 and 1 only
5th May 2020, 9:31 AM
Abhay
Abhay - avatar
+ 1
Thank you! That was close what I wanted but I should have explained better. :D Is it possible to INSERT a random word into the middle of a non-random sentence?
5th May 2020, 10:11 AM
Unrealistic Engineer
Unrealistic Engineer - avatar
+ 1
Yes, in the middle would be great! :))
5th May 2020, 10:15 AM
Unrealistic Engineer
Unrealistic Engineer - avatar
0
I think you want to get a random word from a sentence right?
5th May 2020, 9:34 AM
Arb Rahim Badsa
Arb Rahim Badsa - avatar
0
https://code.sololearn.com/WbVTRn4UE2y4/?ref=app Yes, I was inspired by this. I can create whole random sentences with it but what if I want a random word in the middle of a non-random sentence? How would I do that?
5th May 2020, 9:41 AM
Unrealistic Engineer
Unrealistic Engineer - avatar
0
Unrealistic Engineer Here is how you get a random word from a sentence :)) https://code.sololearn.com/WbkLND0LDb4o/?ref=app Check the js tab :)) Use the getRandomWord function!
5th May 2020, 9:59 AM
Arb Rahim Badsa
Arb Rahim Badsa - avatar
0
Unrealistic Engineer Now that makes total sense. Is it have to be in the exact middle or anywhere in a non-random sentence?
5th May 2020, 10:12 AM
Arb Rahim Badsa
Arb Rahim Badsa - avatar
0
Unrealistic Engineer I think this is as expected. Is it after all? https://code.sololearn.com/WbRuos352saj/?ref=app
5th May 2020, 10:33 AM
Arb Rahim Badsa
Arb Rahim Badsa - avatar
0
Thank you! :) Yes, almost! But would it be possible to have an array of 7 words that get randomly inserted into the sentence?
5th May 2020, 11:26 AM
Unrealistic Engineer
Unrealistic Engineer - avatar