I am currently working on extracting an array from a given input string generated in //PROGRAM 1 for manipulation purposes. While I have found abundant resources on how to manipulate an existing array, my challenge lies in creating the array in the first place.
Essentially, all I need is a function that can take the input string and convert it into an array with each word separated. I might have made some progress with the code "var res = one.split(" ");," but I'm unsure about the subsequent steps needed to calculate and store the length of each word and add extra characters to words exceeding five characters.
(Check out Updated Version Below.) Any suggestions on resolving the error at line 24?
<!DOCTYPE html>
<html>
<head>
<title>Project 1 – Michael Fiorello</title>
<script>
do{
//MAIN MENU
var input = prompt ("Please enter 1, 2, 3, or exit.");{
//PROGRAM 1-Enter the string to be converted to robot speak
if(input == "1")
do{
var one = prompt ("Please enter a string.");{
if (one == "") { console.warn("You need to enter something");}
}
}while (one == "")//keep repeating program 1 until something is entered, aka cannot be blank.
//PROGRAM 2-Convert the string into robot speak
else if (input == "2")
{
if (one == null) {console.warn ("You need to first enter a String")}
else {console.log ("String Converted")
var res = one.split(" ");{
for(i = 0, i<Arr.length, i++)
if(res[i].length >= 5)
{
Document.write(Arr.[i]+"-blip");
}
else{
Document.write(Arr.[i]+"-clang");
}
}
}
}
//Program 3 Robot Language version of the string will appear in the console
else if (input == "3")
{
alert ("AWESOME!");
}
else if (input.toLowerCase() == "exit")
{
alert ("Thanks for using the ROBOT Language Converter!");
}
else
{
alert ("Nope");
console.warn("You need to enter something");
}
}
}while(input.toLowerCase() != "exit");
</script>
</head>
<body>
<h1></h1>
</body>
</html>