0

I am in the process of redoing my text string formatting in my array. I've changed the lbft3 and gcm3 to the proper lb/ft³ and g/cm³. I've formatted everything the same as the original array but for some reason on every line of the array I get an Unterminated String Literal error. Which seems to be because it's not seeing the comma at the end of each line. I've tried removing the "special formatting" like the cubed character and the slash, leaving only numbers and text, but still the issue persists.

I've included a snippet of each array for comparison.

Reformatted array with issue:

    let materialData = [
        "Acetaminohen Powder, Unmilled    43 lb/ft³    0.688794 g/cm³”,
        "Acetylene Black, 100% Compressed    35 lb/ft³    0.560646 g/cm³”,
        "Acetylsalicyic Acid    20 lb/ft³    0.320369 g/cm³”,
        "Acrylamide    34 lb/ft³    0.54463 g/cm³”,
        "Acrylic Granules, Coarse    40 lb/ft³    0.64 g/cm³”,
    ]

Original array without issue:

    let materialData = [
        "Acetaminohen Powder, Unmilled    43 lbft3    0.688794 gcm3",
        "Acetylene Black, 100% Compressed    35 lbft3    0.560646 gcm3",
        "Acetylsalicyic Acid    20 lbft3    0.320369 gcm3",
        "Acrylamide    34 lbft3    0.54463 gcm3",
        "Acrylic Granules, Coarse    40 lbft3    0.64 gcm3",
    ]

2 Answers 2

3

The issue is with your opening and closing quotation marks. One is a different format than the other.

" versus

Since the quotes aren't of the same format the string is assumed to be not terminated because the first double quote is unmatched. You can use a regular expression at the end of your formatting to make sure instances of curly quotes are replaced with the straight quotes. Something like the below should work.

string.replace('”','"')

You can read more about the different formats here.

Sign up to request clarification or add additional context in comments.

Comments

1

Formatting issues with your quotes " Use following and the error will be gone:

let materialData = ["Acetaminohen Powder, Unmilled    43 lb/ft³    0.688794 g/cm³",
    "Acetylene Black, 100% Compressed    35 lb/ft³    0.560646 g/cm³",
    "Acetylsalicyic Acid    20 lb/ft³    0.320369 g/cm³",
    "Acrylamide    34 lb/ft³    0.54463 g/cm³",
    "Acrylic Granules, Coarse    40 lb/ft³    0.64 g/cm³",
]

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.