function concatenateTwoStrings(string1, string2)
{
const string1 = “Fresh”;
const string2 = “Start”;
concatenateTwoStrings(string1, string2);
}
function concatenateTwoStrings(string1, string2)
{
const string1 = “Fresh”;
const string2 = “Start”;
concatenateTwoStrings(string1, string2);
}
You need to stop trying to set the value of <string1>
and <string2>
. Those values are set when someone calls the function.
Im so confused and i feel like i shouldnt be.
So i tried this
function concatenateTwoStrings(string1, string2)
{
concatenateTwoStrings(string1, string2);
}
Now you’re trying to run the function within itself.
Ignore the function line. Instead, think about how you would make string1
and string2
become string1 string2
. How do you put two strings together?
id use .concat() but wont i need actual variables in order for that to work
string1
and string2
ARE variables though. You just don’t define their value in the function, because their value gets defined when I CALL the function.
Im still not sure what to do i took out all variables created and just used the .concat syntax and recieved an error.
function concatenateTwoStrings(string1, string2)
{
string1.concat(’ ', string2));
}
}
You’ve got some extra symbols resulting in syntax errors. But you are moving in the right direction now!
check your parenthesis. You need a closing one for each opening ones, you have extras
also, your function needs to return something. To return something you need to use the return
keyword
Also, please format your code as explained above by ArielLeslie. It is pretty difficult to read code when it is not properly formatted. Properly formatted code also makes a lot easier to catch certain syntax errors.
function concatenateTwoStrings(string1, string2)
{
return (string1.concat(' ', string2));
}
Hey it looks like you’ve got it!
unfortunately it wouldnt pass the run test
Perhaps the space is unnecessary. You can try removing the '',
hallelujah