Chapter projects
Word scrambler
Create a function that returns a value of a word and scrambles the letter order with Math.random()
:
- Create a string that will hold a word value of your choice.
- Create a function that can intake a parameter of the string word value.
- Just like an array, strings also have a length by default. You can use this length to set the loop maximum value. You will need to create a separate variable to hold this value as the length of the string will be decreasing as the loop continues.
- Create an empty temporary string variable that you can use to hold the new scrambled word value.
- Create a
for
loop that will iterate the number of letters within the string parameter starting at 0 and iterating until the original length value of the string is reached. - Create a variable that will randomly select one letter using its index value, with
Math.floor()
andMath.random()
multiplied by the current length of the string. - Add...