Skip to content

Instantly share code, notes, and snippets.

@splincode
Created May 25, 2019 13:30
Show Gist options
  • Save splincode/5d923ac28eeab35cfca54e6c468b36a7 to your computer and use it in GitHub Desktop.
Save splincode/5d923ac28eeab35cfca54e6c468b36a7 to your computer and use it in GitHub Desktop.
function checkLanguage(greeter, closing){
if (closing) {
const newGreeter = clone(greeter);
newGreeter.greeting = 'Goodbye';
return newGreeter;
}
return greeter;
}
const foo = { greeting: 'Hello' };
const newFoo = checkLanguage(foo, true);
console.log(newFoo.greeting + ' world!');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment