Template literal | SoloLearn: Learn to code for FREE!

0

Template literal

Why template literal bot working for me? Also \n Both doesn’t work in simple codes

6/1/2020 5:30:37 PM

Jenan Radhi

4 Answers

New Answer

+10

Jenan Radhi don't use java to write javascript code? • https://www.sololearn.com/learn/JavaScript/1124/ • Template Literals in ES6 - https://www.sololearn.com/learn/JavaScript/2969/ • A guide to javascript template literals — https://flaviocopes.com/javascript-template-literals/ • String interpolation in javascript — https://dmitripavlutin.com/string-interpolation-in-javascript/

+3

JavaScript template literals require backticks, not straight quotation marks. You need to use backticks (otherwise known as "grave accents" - which you'll find next to the 1 key) - rather than single quotes - to create a template literal. Backticks are common in many programming languages but may be new to JavaScript developers. Example: categoryName="name"; categoryElements="element"; console.log(`categoryName: ${this.categoryName}\ncategoryElements: ${categoryElements} `) Output: VM626:1 categoryName: name categoryElements: element

+1

Can you share one of the ailing codes here? it helps others to analyse the problem when they can see your code. In case you didn't know how, you can follow this guide to share your code link. https://www.sololearn.com/post/75089/?ref=app

0

https://code.sololearn.com/cB9IYBozAfj6/?ref=app here is my code when i browse it in chrome it appears at a single line sentence