Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9188353
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T19:59:07+00:00 2026-06-17T19:59:07+00:00

I am writing a program that will take the contents of a text area,

  • 0

I am writing a program that will take the contents of a text area, pull out the important info, format it and then output it.

I have successfully made my program pass all the info into an array.

Currently I am working on getting the program to identify where the customer’s name is located (it will always be between “Name” and either “Details” or “Customer” if “Details” is not in the correct location in the array.

// Parse the input box into an array
var inputArr = document.getElementById("inputBox").value.split(/[\s]/);

// Instantiate variables
var custDet, contactName, phone, companyName, email;

// Pull out all strings between "Name" and "Email" ("Card" should always be after "Email" or else it's the wrong string
if(inputArr[inputArr.indexOf("Email") + 1] == "Card") {
    custDet = inputArr.slice(inputArr.indexOf("Name") + 1, inputArr.indexOf("Email"));  

    // Pass the customer's name into the string contactName
    for(i = 0; custDet[i] != "Details" || custDet[i] != "Customer" || i < custDet.length; i++) {
        if(custDet[i].search(",") != -1) {
            var temp = custDet[i].split(/[,]/);
            temp.reverse();
            contactName = contactName + temp.join(" ");
        }
    }
    contactName = contactName + custDet.join(" ");
} else {
    contactName = prompt("Error: Could not locate a valid Contact Name. Please input Contact Name.");
    phone = prompt("Error: Could not locate a valid Contact Phone Number. Please input Contact Phone Number.");
    companyName = prompt("Error: Could not locate a valid Company Name. Please input Company Name.");
    email = prompt("Error: Could not locate a valid Email Address. Please input Email Address.");
}

The error is being thrown on…

if(custDet[i].search(",") != -1) {

And I don’t understand why. Any help with my logic would also be appreciated.

Thank you all. 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T19:59:09+00:00Added an answer on June 17, 2026 at 7:59 pm

    That error likely means that you tried to reference item i of custDet, but custDet didn’t have that many elements in it.

    Your for loop is “non-standard”:

    for(i = 0; custDet[i] != "Details" || custDet[i] != "Customer" || i < custDet.length; i++) 
    

    and I suspect that’s the source of the problem. i becomes higher than custDet.length, so that means custDet[i] returns undefined. Since undefined != "Details" is true, the loop keeps going past custDet.length.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing a program for iPhone that will first let the user take a
I'm writing a program for an ATMega328P that will take readings from several ADC
So I am busy writing a MIPS program that will take an input string,
I'm writing a Perl program that will take a few command-line arguments (they'll actually
I'm writing a program that will take in an equation and check if all
I'm writing a java program that will take int input as a option from
I'm writing a program that will take sheet music (chords above lyrics) and transpose
I am learning C and writing a simple program that will take 2 string
I am writing a program in python that will take user birthday input and
I just started learning Python... I am writing a simple program that will take

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.