Skip to main content
Dan Rodney/2 min read

Topic 3G: Wrapping Text on Multiple Lines

HTML & CSS Foundations

Semantic HTML

<header>, <nav>, <main>, <article> — describe content meaning.

CSS Selectors

Element, class, ID, descendant, pseudo-class — pick what to style.

Box Model

Content + padding + border + margin — every element follows this.

Responsive Design

Media queries and flexible units for every screen.

Master HTML & CSS at Noble Desktop

Noble Desktop's Full-Stack Web Development Certificate teaches HTML, CSS, and JavaScript — the complete front-end foundation.

Explore how to convert a plain text list into a JavaScript array using Visual Studio Code in this informative Emmet tutorial.

Wrapping Text on Multiple Lines (Convert a List into JavaScript Array)

We can quickly turn a plain text list like this:

Monday
Tuesday
Wednesday
Thursday
Friday
Saturday
Sunday

Into a JavaScript Array like this:

days=['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday']

Here’s How to Do It

These instructions are for Visual Studio Code:

  1. Select the multi-line plain text list (such as the days list above).
  2. Choose Selection > Add Cursors to Line Ends.
  3. To select the entire line, hold Shift and hit the Home key. If you don’t a Home key, hold Shift then fn (the function key) and hit Left Arrow.
  4. Type a single-quote (') to wrap them in quotes.
  5. Press Right Arrow twice to move cursor after the quote.
  6. Type a comma.
  7. Press Right Arrow to go to next line.
  8. Hit Delete (Mac) or Backspace (Windows) to pull everything onto one line.
  9. Delete the extra comma at the end of the line (if there is one).
  10. Select all the list code that’s now on a single line.
  11. Type a left square bracket [ to wrap it in brackets.
  12. In the front of the bracketed code type days= and you should end up with:

    days=['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday']