Tom Lee
Tom Lee

Reputation: 15

Combine elements in an Array

Thank you for reading this question.

let foodArray = ["pasta", "cheese", "banana", "water"]

let expectedOutput = "pasta;cheese;banana;water"

What would be a good way to convert foodArray to expectedOutput?

Thank you.

Upvotes: 1

Views: 109

Answers (1)

Aaron Brager
Aaron Brager

Reputation: 66234

let foodArray = ["pasta", "cheese", "banana", "water"]

let expectedOutput = "pasta;cheese;banana;water"
let actualOutput = join(";", foodArray)

let worked = expectedOutput == actualOutput

worked is true.

Upvotes: 1

Related Questions