How to complete generateHash function?

How to complete generateHash function?

<strong>block.js</strong>

block.js

In block.js, there is a generateHash function. I'm unable to use Promises to calculate the hash asynchronously and update the hash property.

class Block {
constructor(data){
            this.id = 0;
            this.nonce = 144444;
            this.body = data;
            this.hash = "";
        }

generateHash() { // Use this to create a temporary reference of the class object let self = this;

//Implement Promises here

} }

// Exporting the class Block to be reuse in other files
module.exports.Block = Block;

app.js

In app.js, the generateHash function is called and Promises are handled which is pretty clear to me:

const BlockClass = require('./block');

/**

  • Creating a block object
  • / const block = new BlockClass.Block("Test Block");

// Generating the block hash block.generateHash().then((result) => { console.log(Block Hash: ${result.hash}); console.log(Block: ${JSON.stringify(result)}); }).catch((error) => {console.log(error)});


Angular 9 Tutorial: Learn to Build a CRUD Angular App Quickly

What's new in Bootstrap 5 and when Bootstrap 5 release date?

Brave, Chrome, Firefox, Opera or Edge: Which is Better and Faster?

How to Build Progressive Web Apps (PWA) using Angular 9

What is new features in Javascript ES2020 ECMAScript 2020

Top 7 Most Popular Node.js Frameworks You Should Know

Node.js is an open-source, cross-platform, runtime environment that allows developers to run JavaScript outside of a browser. In this post, you'll see top 7 of the most popular Node frameworks at this point in time (ranked from high to low by GitHub stars).

Node.js for Beginners - Learn Node.js from Scratch (Step by Step)

Node.js for Beginners - Learn Node.js from Scratch (Step by Step) - Learn the basics of Node.js. This Node.js tutorial will guide you step by step so that you will learn basics and theory of every part. Learn to use Node.js like a professional. You’ll learn: Basic Of Node, Modules, NPM In Node, Event, Email, Uploading File, Advance Of Node.

Create a global finance blockchain application with Node.js

Create a global finance blockchain application with Node.js smart contracts (replay).Watch Rahell Zubairy develop a Node.js smart contract and web app for a Global Finance with blockchain use case.