Topic 3G: Wrapping Text on Multiple Lines

Free Emmet Tutorial

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

This exercise is excerpted from Noble Desktop’s front-end web development (Emmet coding tips) training materials and is compatible with updates through 2022. To continue learning web development with hands-on training, check out our coding bootcamps in NYC and live online.

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:

Front End Web Design Certificate: Live & Hands-on, In NYC or Online, 0% Financing, 1-on-1 Mentoring, Free Retake, Job Prep. Named a Top Bootcamp by Forbes, Fortune, & Time Out. Noble Desktop. Learn More.
  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']
    
photo of Dan Rodney

Dan Rodney

Dan Rodney has been a designer and web developer for over 20 years. He creates coursework for Noble Desktop and teaches classes. In his spare time Dan also writes scripts for InDesign (Make Book JacketProper Fraction Pro, and more). Dan teaches just about anything web, video, or print related: HTML, CSS, JavaScript, Figma, Adobe XD, After Effects, Premiere Pro, Photoshop, Illustrator, InDesign, and more.

More articles by Dan Rodney

How to Learn HTML & CSS

Master HTML and CSS with hands-on training. HTML (HyperText Markup Language) and CSS (Cascading Style Sheets) are used to build and style webpages.

Yelp Facebook LinkedIn YouTube Twitter Instagram