Convert a given string into an array to enable the manipulation of individual words

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>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

The TypeScript, NextJS project is encountering an issue where it is unable to read the property 'cwd' due to a TypeError

I've noticed this particular error popping up frequently online, but it's not quite matching the issue I'm facing. Every time I execute yarn dev, I encounter the following error: next-dev.js?53bc:89 Error was not caught TypeError: Cannot re ...

Issues with returning undefined values in JSON with Node.js and AngularJS

I have developed an application that communicates with an API to retrieve and display data. The process involves entering a username in the client input, which is then sent to the server. Upon checking, everything seems to be working fine at this stage. H ...

What is the best way to dynamically pass props to the styles hook in Material UI?

Looking for a way to dynamically add background images to div elements? I'm currently iterating over an array of objects and returning divs, but I'm not sure how to set the background image based on the image URL in each object. Can anyone help m ...

Seeking help with a Javascript regex inquiry

I am currently utilizing JavaScript regex for the following task: I have gathered the HTML content from a page and stored it within a string. Now, I aim to identify all URLs present on this page. For instance, if the document includes-- <script src = ...

The issue I'm facing is that the style loader is failing to load the CSS within the <head

I am currently facing an issue with importing my CSS into my webpack bundle for our Angular 1 application. Initially, everything was working fine as we bundled our application using Webpack. The HTML included the bundle and vendor scripts, additional Java ...

TS7006: Argument 'duplicate' is assumed to have an 'any' data type

I am working on a function that will create a button to copy the content of a variable into the clipboard using TypeScript. Below is my attempted code: const [copySuccess, setCopySuccess] = useState(''); const copyToClipBoard = async copyMe => ...

Can you explain how the interactive notification on stackoverflow is generated when you are responding to a question and someone posts a new answer?

Have you ever been in a situation where you're writing an answer to a question, but then someone else posts their response and a popup appears notifying you of the new answer? I'm curious about how that whole process works. It seems like the answ ...

Automatically formatting text upon entering it in Vue.js

I need assistance with auto-formatting the postal code entered by the user. The rule for the postal code is to use the format A0A 0A0 or 12345. If the user inputs a code like L9V0C7, it should automatically reformat to L9V 0C7. However, if the postal code ...

What is the benefit of selecting the <body> element in a click event by utilizing .on() as opposed to .click()?

What are the advantages of using the second code over the first? Is it more efficient to directly select .vote a instead of selecting the body tag? I am in the process of developing a voting system that utilizes AJAX, JSON, and PHP: $('.vote a') ...

Tips for avoiding deleting content within a span element when using contenteditable

I am working on an HTML 5 editor that utilizes the contenteditable tag. Inside this tag, I have a span. The issue arises when all text is removed as the span also gets removed. I want to prevent the removal of the span, how can I achieve this? Here is a s ...

AngularJS error: [ng:areq] The specified argument '...' is not a function and is instead undefined

Starting my project with Angular version 1.5 and above. Below is the code for my controller: 'use strict'; (function(){ class FlamingoController { constructor($http) { this.$http = $http; this.flamingo = []; } $on ...

Cross-Origin Resource Sharing using Express.js and Angular2

Currently, I am attempting to download a PLY file from my Express.js server to my Angular/Ionic application which is currently hosted on Amazon AWS. Here is the Typescript code snippet from my Ionic app: //this.currentPlyFile contains the entire URL docum ...

Three.js fails to display materials

I am currently working on exporting a JSON file from Blender and then rendering it using three.js. As my base code, I have used the following reference: https://github.com/jpetitcolas/webgl-experiments/tree/gh-pages/01-rotating-mesh Initially, when I run ...

Experiencing a snag with implementing Firebase version 9 FCM in Next.js 12

I decided to incorporate push notifications into my Next.js (version 12) app, so I integrated Firebase Cloud Messaging. Here is the implementation: import { initializeApp, getApp, getApps } from "firebase/app" import { getMessaging, getToken } fr ...

What is the most efficient way to add an attribute in jQuery - using the attr() method, passing attributes as a key-value object, or directly?

There are three ways that I am aware of for adding a href attribute with a relative link in jQuery: using (1) .attr(), (2) attributes as key-value pair in an argument, or (3) direct writing (if you know other methods, please share in your response so I can ...

Combining the results of JavaScript comparisons into a unified object array and adding a new value if it matches an existing value within the same

I am interested in consolidating the array to represent the base folder hierarchy. In the array provided, "Level 1" is the lowest level with no children folders. The "other level" contains various folders all under the "Top Level." The array structure is ...

Angular is unable to successfully send a post request to Node

Whenever I click on the submit button on the frontend, it triggers the upload() function. This is how it is implemented in my app.html: <div class="row" style="padding:10px;"> <button type="submit" class="btn btn-primary" style="margin ...

Unlocking the Power of Javascript Promises in FileReader

I am facing an issue with my code. Here is the HTML snippet: <input type='file' multiple> And this is my JavaScript code: var inputFiles = document.getElementsByTagName("input")[0]; inputFiles.onchange = function(){ var fr = new File ...

The hover effect and image opacity adjustment seem to be malfunctioning in my HTML/CSS code

Currently, I am in the midst of a web project and my goal is to implement a hover effect on the first card containing an image. The desired outcome is for the card to move upwards upon hovering, allowing the image to become fully visible with an opacity se ...

Converting JSON object to an array or list using deserialization

I'm not sure what to ask, so I apologize if this is poorly thought out. The other questions I have found are about people receiving object arrays in JSON. Instead of an array, my JSON string is returning as an object. This is new for me because I hav ...