Skip to content

Instantly share code, notes, and snippets.

@chathurangat
Last active January 30, 2018 08:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chathurangat/e82df30b7e8a525bcac4ce4a41892ca5 to your computer and use it in GitHub Desktop.
Save chathurangat/e82df30b7e8a525bcac4ce4a41892ca5 to your computer and use it in GitHub Desktop.
import {Calculator} from "./src/calculator";
import {getWelcomeMessage} from "./src/welcome";
//invoking the static add() method
let addition = Calculator.add(10, 20);
//invoking the non-static multiply() method
let multiplication = new Calculator().multiply(20, 5);
document.getElementById("welcome-text").textContent = getWelcomeMessage("chahturanga");
document.getElementById("calculator-text").textContent = " (10 + 20 = [" + addition + "]) and (20 * 5 = [" + multiplication + "])";
//Calculator class is assigned to window. so this class can be accessed from browser
window.Calculator = Calculator;
//getWelcomeMessage function is assigned to window. so the function can be accessed from browser
window.getWelcomeMessage = getWelcomeMessage;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment