JSFiddle - React, Tailwind, and code Playground

by graphettion

HTML

<script src="https://cdnjs.cloudflare.com/ajax/libs/typescript/2.2.0/typescript.min.js"></script>

TypeScript

'use strict';

//Cache the DOM
const body = document.body;

//Data Types
interface Person {
  firstName: string;
  lastName: string;
};

//Student object
class Student {
  fullName: string;
  constructor(private firstName, private middleInitial, private lastName) {
    this.fullName = `${this.firstName} ${this.middleInitial} ${this.lastName}`;
  };
  render(person : Person) {
    return body.innerText += `Hello, ${this.firstName} ${this.lastName}`;
  };
};

//Instantiate Student object
var user = new Student("Jane", "M.", "Doe");

//Render Student object
user.render();