Nested JavaScript string template

How do I nest strings template?

I want the line ${ {count} {db[count]} } to std:out such that the ${count+1} and ${db[count]}
are logged to the console on the same line
like this
1. value corrsponding to one

Here’s my code in JS

  //define possible meeting occasion 
  let db = [
'\n seen me in person',
'\n touched me',
'\n hugged me ',
'\n spent an hour with me',
'\n ate with me ',
'\n walked beside me ',
'\n see me smile'
];

  // data to toUpperCase
  db = db.map(db => db.toUpperCase());

  let feedBack = [];
  for (let count = 0; count < db.length; count++) {
   let met = prompt(`
 	🙋Hi there\ !
 	How well do you know me?
 	Let\'s see...🕵🏼Reply with any of
 	${ {count} {db[count]} } \n `, ' ');


   feedBack.push(met);
   //loop thru db

  }
  alert(feedBack);

I already tried ${{count+1} {db[count]}
and ${count+1}.${db[count]}
none worked. :cry:

This template is looking for {count} that does not exists.
I think what you want is to have both variables inside your string, right?

So something like

${count} ${db[count]}

Hope it helps :slight_smile:

And also mind that the strings in the db starts with a new line, remember to clean it before logging it :sparkles:

  let db = [
' seen me in person',
' touched me', ...]


 	${count +1}. ${db[count]}  \n `, ' ');

Corrections made. All good :yum:. Thanks for the assitance. It worked

Glad it worked.
Happy coding :sparkles:

1 Like