Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Basic Array Question

Community Beginner ,
Sep 21, 2017 Sep 21, 2017

For a class I'm using this code.

var testArray:Array = ["Anthony", "Shari", "Blake", "Paul", "Duke"];

testArray.forEach(displayText);

function displayText (element:*, index:int, arr:Array):void {

    trace ("Current element value is: + element);

    trace ("Current index value is: " +index);

    trace ("All array elements: " + arr);

}

I'm getting several error messages I do not understand.

Scene 1, Layer 'Layer 1', Frame 1, Line 6, Column 9    1095: Syntax error: A string literal must be terminated before the line break.

Scene 1, Layer 'Layer 1', Frame 1    1084: Syntax error: expecting rightbrace before end of program.

please Help?

341
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Sep 21, 2017 Sep 21, 2017

var testArray:Array = ["Anthony", "Shari", "Blake", "Paul", "Duke"];

testArray.forEach(displayText);

function displayText (element:*, index:int, arr:Array):void {

    trace ("Current element value is: + element);  // <- this line is missing a double quote

    trace ("Current index value is: " +index);

    trace ("All array elements: " + arr);

}

Translate
Community Expert ,
Sep 21, 2017 Sep 21, 2017

var testArray:Array = ["Anthony", "Shari", "Blake", "Paul", "Duke"];

testArray.forEach(displayText);

function displayText (element:*, index:int, arr:Array):void {

    trace ("Current element value is: + element);  // <- this line is missing a double quote

    trace ("Current index value is: " +index);

    trace ("All array elements: " + arr);

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Sep 21, 2017 Sep 21, 2017

Well, that's embarrassing, thank you.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 21, 2017 Sep 21, 2017
LATEST

you're welcome.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines