I just asked this question and i thought it was resolved but it isnt.. so here it is again.. apologies for the double post..
I have a file: block.js:
class Block{
constructor(timeStamp, lastBlockHash, thisBlockData, thisBlockHash){
this.timeStamp = timeStamp;
this.lastBlockHash = lastBlockHash;
this.thisBlockData = thisBlockData;
this.thisBlockHash = thisBlockHash;
}
static genesis(){
return new Block(Date.now(), "---", "This is the genesis block", "hash of the genesis");
}
}
another file: blockchain.js:
const Block = require('./block');
class BlockChain{
constructor() {
this.chain = Block.genesis();
}
}
module.exports = {BlockChain};
and finally a test file test.js:
const BlockChain = require("./blockchain.js");
let blockChainInstance = new BlockChain();
console.log(blockChainInstance.chain);
the output of the test.js file is showing "undefined" in place of a genesis block.. this has been a mystery for me since morning.. and i would be immensely grateful if anyone can solve this for me..
Cheers, al