Functions/Name/

Functions/Name/
0.0 0

#1

Hi guys!!! Okay so I’ve created a name function and I have two names for a return. Although one returned I can’t get other to do the same. How would I do this?

function fullName(firstName,lastName) {
   fullname =("Clark" , "Kent");
   return 'Clark Kent';
}

function fullName(firstName,lastName){
    fullname =("Jonah" , "Hex");
}

#2

Here’s the link…


#3

Hmmmmmm… that website looks suspiciously similar to Free Code Camp except for the not free part.

OK - you don’t write two functions - one for Clark Kent and another for Jonah Hex. You write one function that could handle any number of names. You give the function a first and a last name and it returns you those two as one string with a space between them.

Kind of like

// write code below this line
function fullName(first, last){
   var full = // some code to make name into one string 
   return full;
}
// write code above this line

// use the function like this
var firstName = "Donald";
var lastName = "Duck";

console.log( fullName(firstName, lastName) ); //prints Donald Duck

var user1 = fullName( "John", "Doe");
console.log( user1 );  //prints John Doe


#5

Yes - this seems to be freeCodeCamp’s code. We are BSD-3 licensed, so they’re welcome to use our code as long as they don’t use the names of freeCodeCamp or any of our contributors as an “endorsement” of their products or services.


#6

I’ve edited your post for readability. When you enter a code block into the forum, precede it with a line of three backticks and follow it with a line of three backticks to make easier to read. See this post to find the backtick on your keyboard. The “preformatted text” tool in the editor (</>) will also add backticks around text.