So I’m working with this code for a blockchain mining class
JavaScript
x
15
15
1
const Block = require('./Block');
2
class Blockchain{
3
constructor(){
4
this.chain = [Blockchain.genesis()];
5
}
6
addBlock({data}){
7
const newBlock = Block.mineBlock([
8
lastBlock: this.chain[this.chain.length-1],
9
data
10
]);
11
this.chain.push();
12
}
13
}
14
module.exports = Blockchain;
15
And I keep getting this error Unexpected token, expected , (8:21)
, for this line:
JavaScript
1
2
1
lastBlock: this.chain[this.chain.length-1],
2
Any help will be appreciated!
Advertisement
Answer
Try Using this
JavaScript
1
6
1
Block.mineBlock({
2
lastBlock: this.chain[this.chain.length-1],
3
data
4
})
5
6
Seems to me like you key:value
pairs are not properly formatted..
The code in probably taking
JavaScript
1
2
1
lastBlock: this.chain[this.chain.length-1],
2
this above line as Key and is expecting a value from data