DEV Community

ayush65
ayush65

Posted on

Ayush

Chalk module in Node.js is the third-party module that is used for styling the format of text or create our own theme in the node.js project

for the neog.camp in the mark 1 i learn about it and used in my program .

A small part of program is as follows :-

we can use even const and var as per our choice.

output

we have to first write the following code for importing the module
Now ,
var variable = require('readline-sync');

Using readline-sync helps us to get the user input later if we want in our program

eg:- In this program we want to check that the user is correct or not about the questions provided .

Now,
const chalk = require('chalk');

chalk is a variable here you can use any name as you want for the variable .

we have to import chalk module is used for providing the color for for the console.log() as we discussed earlier

output

here using the chalk.blue we can get the blue color for the console.log part as :-

output

We can use the chalk module as a variable also :-

Alt Text

We can use in the console.log() as :-

console.log(welcome('you are right! '));

console.log(warning('oops! its wrong'));
Enter fullscreen mode Exit fullscreen mode

We will assign the score for the small CLI app game :-

Initially the score will be zero .

output

for last defining part we can use it with console.log as shown below :-

output

you can check the project on :- https://replit.com/@ayush65pra/my-quiz?embed=1&output=1#index.js
thanks for giving your valuable time .

Top comments (0)