yodacom
10/31/2016 - 1:25 PM

string concatenation function

string concatenation function

function wisePerson(wiseType, whatToSay) {
  return 'A wise ' + wiseType + ' once said: "' +
      whatToSay + '".';
}

/* 
Say it with ES6

return ` 'A wise ${wiseType} once said: "${whatToSay}".`
   
*/


// tests

function testWisePerson() {
  var wiseType = 'goat';
  var whatToSay = 'hello world';
  var expected = 'A wise ' + wiseType + ' once said: "' +
      whatToSay + '".';
  var actual = wisePerson(wiseType, whatToSay);
  if (expected === actual) {
    console.log('SUCCESS: `wisePerson` is working');
  }
  else {
    console.log('FAILURE: `wisePerson` is not working');
  } 
}

testWisePerson();