What you did here is wrong,instead,you have two options:
1)(The regular way):
Pass a variable and return it:
function helloWorld(str){
str="hello world"
return str;
}
let hw=helloWorld(hw);
console.log(hw); //prints hello world
- pass a object to a function and get 2 fields (hello,world) inside the object (note: This might override another values,if the fields hello or world already exists inside the passed object)
function helloWorld(a){
a.hello="hello";
a.world="world";
}
let hw={};
helloWorld(hw);
console.log(hw.hello+" "+hw.world); // prints hello world