You're missing backticks around the string you're trying to interpolate

Wrap this string: URL('....${number})' in backticks, backtick: `

Answer from Queens Coder on Stack Overflow
🌐
Codecademy Forums
discuss.codecademy.com › frequently asked questions › javascript faq
Why isn't string interpolation working? (Check for backticks) - JavaScript FAQ - Codecademy Forums
January 7, 2019 - Why isn’t my interpolation working: console.log(‘My name is {myName}. My favorite city is {myCity}.’); The syntax looks right. It just prints the literal characters ${myName} without reading them as a variable. It seems to be bugged. If I type it, the console doesn’t recognise the variable as a variable, but as a string.
🌐
Reddit
reddit.com › r/learnprogramming › javascript string interpolation not working
r/learnprogramming on Reddit: javascript string interpolation not working
June 4, 2020 -

I have the following function.

function hello() {
var name = 'John';
var age = 32;
console.log('My name is ${name}, and I am ${age} years old');
}

After calling the function it does not interpolate the string placeholders. Therefore the output is:

My name is ${name}, and I am ${age} years old

I have tried this in node and in chrome. I have tried in a file.js file then called it with node in the terminal.

My current version of node is v14.11.0

Am I crazy and missing something here?

🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Template_literals
Template literals (Template strings) - JavaScript | MDN
Dollar signs can be escaped as well to prevent interpolation. ... Any newline characters inserted in the source are part of the template literal. Using normal strings, you would have to use the following syntax in order to get multi-line strings:
🌐
W3docs
w3docs.com › javascript
How to Do String Interpolation in JavaScript
Javascript string interpolation and placeholder expression · const NUM = 8.3; console.log(`The number is ${NUM}`); ... It is important that any string that uses interpolation be wrapped in backticks (`), not “double quotes” or ‘single quotes’. When you use backticks, you create a Template Literal, which is just a string that can accept embedded code.
🌐
GitHub
github.com › marko-js › marko › issues › 545
String interpolation not working in latest v3 · Issue #545 · marko-js/marko
Our template with string interpolation in the <script> tag is not working as it was before (in v3.9).
🌐
freeCodeCamp
forum.freecodecamp.org › javascript
What is wrong with the string interpolation here - JavaScript - The freeCodeCamp Forum
March 15, 2021 - here in react native , I am getting error while attempting this expand[0] is true/false error name simply syntax error
🌐
Cycling '74
cycling74.com › forums › javascript-string-interpolation-template-literals-template-strings
javascript string interpolation / template literals / template strings - Misc Forum | Cycling '74
Using the js object I tried to employ string interpolation, but got the error: "js: midi2notename.js: Javascript SyntaxError: illegal character, line 11". I'm aware of the workaround to concatenate the generated string with "\n", but was wondering why there's this deviation from the standard [Template literals (Template strings) - JavaScript | MDN]
Find elsewhere
🌐
Coffeescript-cookbook
coffeescript-cookbook.github.io › chapters › strings › interpolation
CoffeeScript Cookbook » String Interpolation
Use CoffeeScript’s ruby-like string interpolation instead of JavaScript’s string addition. You must use Double-quoted strings to allow for interpolation.
🌐
TutorialsPoint
tutorialspoint.com › how-to-do-string-interpolation-in-javascript
How to do string interpolation in JavaScript?
String interpolation in JavaScript is a process in which an expression is inserted or placed in the string. To insert or embed this expression into the string a template literal is used. By using string interpolation in JavaScript, values like variab
🌐
Sublime Forum
forum.sublimetext.com › t › js-template-literals-string-interpolation-snippet-not-working-as-expected › 40841
JS Template literals (string interpolation) snippet not working as expected - Technical Support - Sublime Forum
September 29, 2018 - Consider the following snippet… $ JS - String Interpolation source.js The idea is to create a snippet which inserts ${someVar} into a JS document when you autocomplete on the $ key. It works fine on its own in a JS document. However whenever it’s within back ticks as required for JS Template Literals it autocompletes to .
🌐
GeeksforGeeks
geeksforgeeks.org › string-interpolation-in-javascript
String Interpolation in JavaScript | GeeksforGeeks
November 21, 2024 - You can use an array and the join() method to interpolate strings, though this is less common and more verbose. ... Hello, Alice! A custom function can be used to handle string interpolation, especially if the string structure is complex or repeated.
🌐
Dmitri Pavlutin
dmitripavlutin.com › string-interpolation-in-javascript
String Interpolation in JavaScript
March 21, 2023 - In JavaScript, there are 3 ways to create string literals. The first, which I prefer for plain strings, is to wrap the string into a pair of single quotes ': ... The string literal wrapped in backticks ` is also named template string. This is the literal that supports the string interpolation.
🌐
Mastering JS
masteringjs.io › tutorials › fundamentals › string-interpolation
JavaScript String Interpolation - Mastering JS
`Hello ${void 0}!`; // "Hello undefined!" The only case where string interpolation can throw a runtime error is if your placeholder expression evaluates to an object whose toString() function throws an error.
🌐
Career Karma
careerkarma.com › blog › javascript › javascript string interpolation: a beginner’s guide
JavaScript String Interpolation: A Beginner’s Guide | Career Karma
December 1, 2023 - JavaScript string interpolation is supported in template literals. On Career Karma, learn how to add values inside a string using template literals.
🌐
Flexiple
flexiple.com › javascript › javascript-string-interpolation
JavaScript String Interpolation - Flexiple
The use of backticks (`) rather than quotes (' or ") to define template literals is essential for enabling interpolation. This method not only improves readability but also reduces the potential for errors that frequently occur in complex string concatenation scenarios. In JavaScript, string literals are sequences of characters used directly in code, enclosed either by single quotes ('), double quotes ("), or backticks (`), similar to how expressions are evaluated within the ternary operator.