0

I want to have the variable, which name will be contacted var and string

function(name){
  var name + "string" = ...
}

2 Answers2

0

You should use bracket notation and insert variables inside an object.

Something like this:

var createName = function(name, container){
  container[name + "String"] = 'He is Beautiful, I love him. <3';
  return container;
}

If you call

createName('Rodmentou', names);
console.log(names[RodmentouString]);

You will receive, as output:

He is Beautiful, I love him. <3

Rodmentou
  • 1,610
  • 3
  • 21
  • 39
-2

Your question is not clear and does not make sense to programmer. Anyway, to concatenate a string with another string you can use concat function.

var str1 = "Hello ";
var str2 = "world!";
var res = str1.concat(str2); // 'Helloworld'
 or
var res = str1.concat('world'); // 'Helloworld'

or you can use '+' operator :

 var str1 = "Hello ";
    var str2 = "world!";
   var str = str1 + str2; // 'Helloworld'
   var str = 'Hello'+'world'; // 'Helloworld'
Abdus Sattar Bhuiyan
  • 3,016
  • 4
  • 38
  • 72