Skip to content

Instantly share code, notes, and snippets.

@umesh1702
umesh1702 / nodejs assignment-2.md
Last active January 19, 2024 07:00
Node.js Script for Product Catalog Management

Objective:

Create a Node.js script that manages a product catalog with three categories: books, clothing, and electronics. The script should generate JSON files for each category with at least 10 entries, each containing properties such as ID, name, type, price, discount, and currency. The user should be able to interactively choose a category (1 for books, 2 for clothing, 3 for electronics), and the script should display the corresponding items in a table format.

Requirements:

** Category Data: Generate data for books, clothing, and electronics categories in json format. Each entry should include properties: ID, name, type, price, discount, and currency.

@umesh1702
umesh1702 / productCatalogViewer.js
Created January 18, 2024 03:13
Node.js script that creates three JSON files (books.json, clothing.json, electronics.json) with sample entries and allows the user to choose a category (books, clothing, or electronics) and then displays the corresponding items in a table format:
const fs = require('fs');
const inquirer = require('inquirer');
const Table = require('cli-table');
// Sample data for books, clothing, and electronics
const booksData = [
{ id: 1, name: 'Book 1', type: 'Fiction', price: 20, discount: 5, currency: 'USD' },
// Add more book entries...
];