What is React?

React is a front-end JavaScript library.

React was developed by the Facebook Software Engineer Jordan Walke.

React is also known as React.js or ReactJS.

React is a tool for building UI components.

JavaScript Function Syntax

A JavaScript function is defined with the function keyword, followed by a name, followed by parentheses ().

function name(parameter1, parameter2, parameter3) {
  // code to be executed
}

Function Return

When JavaScript reaches a return statement, the function will stop executing.

If the function was invoked from a statement, JavaScript will "return" to execute the code after the invoking statement.

Functions often compute a return value. The return value is "returned" back to the "caller":
Example

Calculate the product of two numbers, and return the result:

// Function is called, the return value will end up in x
let x = myFunction(4, 3);

function myFunction(a, b) {
// Function returns the product of a and b
  return a * b;
}

Why Functions?

With functions you can reuse code

You can write code that can be used many times.

You can use the same code with different arguments, to produce different results.

Arrow functions in JavaScript

productlist.map((product)=>{
    console.log(product.name);
    console.log(product.price);
  })

Open a new folder and Right click open Terminal and give the below command:

1.create react app
npx create-react-app ecommercefrontend .

1.1 To run project
cd inside the folder
npm start

import logo from './logo.svg';
import './App.css';

function App() {
  const prod1={
    img:"url",
    name:"apple",
    price:65000

  }
  const prod2={
    img:"url",
    name:"vivo",
    price:6000

  }
  const productlist=[prod1,prod2];
  //console.log(productlist[1].name)

  productlist.map((product)=>{
    console.log(product.name);
    console.log(product.price);
  })

  return (
    
      

      
    
  );
}

export default App;

In react result page Rigth click and click Inspect(Q) new page will appears in that page go to console to see output..

Image description

neelakandan@neelakandan-HP-Laptop-15s-eq2xxx:~$ sudo -i -u postgres
[sudo] password for neelakandan:         
postgres@neelakandan-HP-Laptop-15s-eq2xxx:~$ psql
psql (16.8 (Ubuntu 16.8-0ubuntu0.24.04.1))
Type "help" for help.

postgres=# \l
postgres=# \c ecommerce
You are now connected to database "ecommerce" as user "postgres".
ecommerce=# \d
Did not find any relations.
ecommerce=# GRANT ALL PRIVILEGES ON SCHEMA public TO ecom3;
GRANT
ecommerce=# \d
             List of relations
 Schema |      Name      |   Type   | Owner 
--------+----------------+----------+-------
 public | cart           | table    | ecom3
 public | cart_id_seq    | sequence | ecom3
 public | payment        | table    | ecom3
 public | payment_id_seq | sequence | ecom3
 public | product        | table    | ecom3
 public | product_id_seq | sequence | ecom3
(6 rows)

ecommerce=# insert into product(name, description,url, rating, price, stock)
values('prod-1', 'Good prod', 'link-1',4, 10000,10);
ERROR:  column "url" of relation "product" does not exist
LINE 1: insert into product(name, description,url, rating, price, st...
                                              ^
ecommerce=# ^C
ecommerce=# ^C
ecommerce=# insert into product(name, description, url, rating, price, stock)
values('prod-1', 'Good prod', 'link-1', 4, 10000, 10);
ERROR:  column "url" of relation "product" does not exist
LINE 1: insert into product(name, description, url, rating, price, s...
                                               ^
ecommerce=# \d product
ecommerce=# ^[[200~ALTER TABLE product ADD COLUMN url TEXT;
ERROR:  syntax error at or near "

ecommerce=# ALTER TABLE product ADD COLUMN url TEXT;//alter table
ALTER TABLE
ecommerce=# insert into product(name, description, url, rating, price, stock)
values('prod-1', 'Good prod', 'link-1', 4, 10000, 10);
INSERT 0 1
ecommerce=# \d//table
 public | cart           | table    | ecom3
 public | cart_id_seq    | sequence | ecom3
 public | payment        | table    | ecom3
 public | payment_id_seq | sequence | ecom3
 public | product        | table    | ecom3
 public | product_id_seq | sequence | ecom3

ecommerce=# \c//conect database
You are now connected to database "ecommerce" as user "postgres".
ecommerce=# \l
ecommerce=# select * product;
ERROR:  syntax error at or near "product"
LINE 1: select * product;
                 ^
ecommerce=# ^C
ecommerce=# SELECT * FROM product;//inside table
  1 | Good prod   |     | prod-1 | 10000 |      4 |    10 | link-1

ecommerce=# 
ecommerce=# \c product_cad ;
You are now connected to database "product_cad" as user "postgres".
product_cad=# drop database ecommerce;
ERROR:  database "ecommerce" is being accessed by other users
DETAIL:  There are 10 other sessions using the database.