Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ashleygwilliams/f9d740813ec9fb36fe146a89ea1e14a1 to your computer and use it in GitHub Desktop.
Save ashleygwilliams/f9d740813ec9fb36fe146a89ea1e14a1 to your computer and use it in GitHub Desktop.
// given a certain state, return the value of a variable
// STATE:
// variables: [a, b, c]
// values: { a: 5, b: a, c: 1 }
//
// value_of: b
value_of(variable) {
var val_vars = Object.keys(this.values);
if (variable.name != 'undefined' && val_vars.indexOf(variable.name) !== -1) {
var val = this.values[variable.name]
return this.value_of(val);
} else {
return variable;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment