You are on page 1of 2

index.

js

import React from "react";


import ReactDOM from "react-dom";
import App from "./App"

ReactDOM.render(
<App/>,document.getElementById('root')
);

-----------------------------------------------------------------------------------
-------

Cal.jsx

function add(a,b){
let sum = a+b
return sum;
}

function sub(a,b){
let sub = a-b
return sub;
}

function mul(a,b){
let mul = a*b
return mul;
}

function div(a,b){
let div = a/b
div = div.toFixed(2);
return div;
}

export {add,sub,mul,div};

--------------------------------------------------------------------

App.js

import React from "react";


import {add,sub,mul,div} from "./components/Calc";

function App(){
return (
<>
<ul>
<li>{add(40, 4)}</li>
<li>{sub(40, 4)}</li>
<li>{mul(40, 4)}</li>
<li>{div(40, 3)}</li>
</ul>
</>
);
}

export default App;

You might also like