simple blockchain in node.js

// Authored by Daniel Picard
import  CryptoJS from 'crypto-js';

class Block {
  constructor(index, previousHash, timestamp, data, hash) {
    this.index = index;
    this.previousHash = previousHash.toString();
    this.timestamp = timestamp;
    this.data = data;
    this.hash = hash.toString();
  }

}

var calculateHash = (index, previousHash, timestamp, data) => {
  return CryptoJS.SHA256(index + previousHash + timestamp + data).toString();
};

var generateNextBlock = (blockData) => {
  var previousBlock = getLatestBlock();
  var nextIndex = previousBlock.index +1;
  var nextTimestamp = new Date().getTime() / 1000;
  var nextHash = calculateHash(nextIndex, previousBlock.hash, nextTimestamp, blockData);
  return new Block(nextIndex, previousBlock.hash, nextTimestamp, blockData, nextHash);
};

var calculateHashForBlock = (blockData) => {
  return calculateHash(blockData.index, blockData.prevousHash, blockData.timestamp, blockData.data);
}

var getGenesisBlock = () => {
  return new Block(0, "0", 1465154705, "my genesis block!!", "816534932c2b7154836da6afc367695e6337db8a921823784c14378abed4f7d7");
}

var blockchain = [getGenesisBlock()];

var isValidNewBlock = (newBlock, previousBlock) => {
  if (previousBlock.index +1 !== newBlock.index) {
    console.log('invalid index')
    return false;
  } else if (previousBlock.hash !== newBlock.prevousHash) {
    console.log('invalid prevous hash value')
    return false;
  } else if (calculateHashForBlock(newBlock) !== newBlock.hash) {
    console.log('invalid hash: ' + calculateHashForBlock(newBlock) + ' ' + newBlock.hash);
    return false;
  }
  return true;
}