const names = ['Jin', 'Kazuya', 'Heiachi']
function Intro(parameter1) {
document.write("My name is " + parameter1 + );
}
Intro(names[2], ' salesman', ' Chicago');
console.log(intro); // this works,
// But how come this does not work?
function Intro(names[2]){
document.write.("My name is + names[2]);
}
Intro(names[2]);
console.log(intro); //not working....
What do you mean by work and not working? Is the result not the one expected? Is there some kind of error?
console.log(intro); // this works,
There is no intro variable in the code you posted, what does that log?
By the way, the difference between the first call to Intro and the second are few:
In the second call you missed a double quote^^
names[2] will result in a single element of the array while parameter1 is composed by three string ( and there is a plus sign at the end of the string quite weird :stuck_out_tongue
When you use names[2] in the second ‘definition’ of Intro it will be considered as a parameter named names[2], not as the third element of the above array ^^
there is a dot just before the parenthesis that is not supposed to be there ( in your second ‘definition’ of the Intro function)^^
Thank you so much for the feedback. Let me try to clarify it a bit better
const names = ['Jin', 'Kazuya', 'Heiachi']
function Intro(parameter1) {
document.write("My name is " + parameter1);
}
Intro(names[2]);
console.log(intro); // this works, I get : "My name is Jin"
// But how come this does not work?
function Intro(names[2]){
document.write("My name is + names[2]);
}
Intro(names[2]);
console.log(intro); // not working " I get : (My name is names[2])"