Sign in
Log inSign up

challenge-invoking-functions

miguelmanalo's photo
miguelmanalo
·May 12, 2020

the intended solution made use of returning to each subsequent function, and then returning str at the end. I guess I gotta think about using return more?

csx.codesmith.io/units/functions-execution…

Challenge: Invoking Functions Examine the code given to you. Try to make the calls variable equal to 'JerryKramerGeorgeElaine' with only a single invocation to the function jerry.

let calls = "";

function jerry(str) {
  //go here first
  //add jerry to str
    str += `Jerry`;
  //go to kramer
  kramer(str);
  //is this working?
  console.log(str, `jerry str`);
}

function george(str) {
    str += `George`;
  elaine(str);
  console.log(str, `george str`);
}

function elaine(str) {
    str += `Elaine`;
  console.log(str, `elaine str`);
  calls = str;
  console.log(calls);
}

function kramer(str) {
    str += `Kramer`;
  george(str);
  console.log(str, `kramer str`);
}

// should return: 'JerryKramerGeorgeElaine'
calls = jerry(calls);