Merge 401179ec6d
into 8b41cd49c3
commit
0d41437888
@ -0,0 +1,9 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<title>30DaysOfScript: Inline Script</title>
|
||||||
|
</head>
|
||||||
|
<body onclick="alert('Welcome to 30DaysOfJavaScript!')">
|
||||||
|
Click Me
|
||||||
|
</body>
|
||||||
|
</html>
|
File diff suppressed because it is too large
Load Diff
@ -1,116 +1,51 @@
|
|||||||
// index.js
|
// index.js
|
||||||
import React from 'react'
|
//index.js
|
||||||
import ReactDOM from 'react-dom'
|
// importing the react and react-dom package
|
||||||
// To get the root element from the HTML document
|
import React from "react";
|
||||||
import asabenehImage from './images/asabeneh.jpg'
|
import ReactDOM from "react-dom";
|
||||||
|
|
||||||
// to import the doSomeMath from the math.js with or without extension
|
|
||||||
import doSomeMath from './math.js'
|
|
||||||
|
|
||||||
// to import the other modules
|
|
||||||
// since these modules were not exported as default we have to desctructure
|
|
||||||
import { addTwo, multiply, subtract } from './math.js'
|
|
||||||
|
|
||||||
import * as everything from './math.js'
|
|
||||||
console.log(addTwo(5, 5))
|
|
||||||
console.log(doSomeMath.addTwo(5, 5))
|
|
||||||
console.log(everything)
|
|
||||||
// JSX element, header
|
|
||||||
|
|
||||||
|
|
||||||
// JSX element, header
|
|
||||||
const welcome = 'Welcome to 30 Days Of React'
|
|
||||||
const title = 'Getting Started React'
|
|
||||||
const subtitle = 'JavaScript Library'
|
|
||||||
const author = {
|
|
||||||
firstName: 'Asabeneh',
|
|
||||||
lastName: 'Yetayeh',
|
|
||||||
}
|
|
||||||
const date = 'Oct 2, 2020'
|
|
||||||
|
|
||||||
// JSX element, header
|
// JSX element, header
|
||||||
const header = (
|
const header = (
|
||||||
<header>
|
<header>
|
||||||
<div className='header-wrapper'>
|
<h1>Welcome to 30 Days Of React</h1>
|
||||||
<h1>{welcome}</h1>
|
<h2>Getting Started React</h2>
|
||||||
<h2>{title}</h2>
|
<h3>JavaScript Library</h3>
|
||||||
<h3>{subtitle}</h3>
|
<p>Ananth Vankipuram</p>
|
||||||
<p>
|
<small>Nov 14, 2021</small>
|
||||||
Instructor: {author.firstName} {author.lastName}
|
|
||||||
</p>
|
|
||||||
<small>Date: {date}</small>
|
|
||||||
</div>
|
|
||||||
</header>
|
</header>
|
||||||
)
|
);
|
||||||
|
|
||||||
const numOne = 3
|
|
||||||
const numTwo = 2
|
|
||||||
|
|
||||||
const result = (
|
|
||||||
<p>
|
|
||||||
{numOne} + {numTwo} = {numOne + numTwo}
|
|
||||||
</p>
|
|
||||||
)
|
|
||||||
|
|
||||||
const yearBorn = 1820
|
|
||||||
const currentYear = new Date().getFullYear()
|
|
||||||
const age = currentYear - yearBorn
|
|
||||||
const personAge = (
|
|
||||||
<p>
|
|
||||||
{' '}
|
|
||||||
{author.firstName} {author.lastName} is {age} years old
|
|
||||||
</p>
|
|
||||||
)
|
|
||||||
|
|
||||||
// JSX element, main
|
|
||||||
const techs = ['HTML', 'CSS', 'JavaScript']
|
|
||||||
const techsFormatted = techs.map((tech) => <li>{tech}</li>)
|
|
||||||
|
|
||||||
const user = (
|
|
||||||
<div>
|
|
||||||
<img src={asabenehImage} alt='asabeneh image' />
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
|
|
||||||
// JSX element, main
|
// JSX element, main
|
||||||
const main = (
|
const main = (
|
||||||
<main>
|
<main>
|
||||||
<div className='main-wrapper'>
|
<p>Prerequisite to get started react.js:</p>
|
||||||
<p>
|
<ul>
|
||||||
Prerequisite to get started{' '}
|
<li>HTML</li>
|
||||||
<strong>
|
<li>CSS</li>
|
||||||
<em>react.js</em>
|
<li>JavaScript</li>
|
||||||
</strong>
|
</ul>
|
||||||
:
|
|
||||||
</p>
|
|
||||||
<ul>{techsFormatted}</ul>
|
|
||||||
{result}
|
|
||||||
{personAge}
|
|
||||||
{user}
|
|
||||||
</div>
|
|
||||||
</main>
|
</main>
|
||||||
)
|
);
|
||||||
|
|
||||||
const copyRight = 'Copyright 2020'
|
|
||||||
|
|
||||||
// JSX element, footer
|
// JSX element, footer
|
||||||
const footer = (
|
const footer = (
|
||||||
<footer>
|
<footer>
|
||||||
<div className='footer-wrapper'>
|
<p>Copyright 2020</p>
|
||||||
<p>{copyRight}</p>
|
|
||||||
</div>
|
|
||||||
</footer>
|
</footer>
|
||||||
)
|
);
|
||||||
|
|
||||||
// JSX element, app
|
// JSX element, app, a container or a parent
|
||||||
const app = (
|
const app = (
|
||||||
<div className='app'>
|
<div>
|
||||||
{header}
|
{header}
|
||||||
{main}
|
{main}
|
||||||
{footer}
|
{footer}
|
||||||
</div>
|
</div>
|
||||||
)
|
);
|
||||||
|
|
||||||
const rootElement = document.getElementById('root')
|
const rootElement = document.getElementById("root");
|
||||||
// we render the JSX element using the ReactDOM package
|
// we render the JSX element using the ReactDOM package
|
||||||
ReactDOM.render(app, rootElement)
|
// ReactDOM has the render method and the render method takes two argument
|
||||||
|
ReactDOM.render(app, rootElement);
|
||||||
|
// or
|
||||||
|
// ReactDOM.render([header, main, footer], rootElement)
|
||||||
|
@ -1,12 +0,0 @@
|
|||||||
// math.js
|
|
||||||
export const addTwo = (a, b) => a + b
|
|
||||||
export const multiply = (a, b) => a * b
|
|
||||||
export const subtract = (a, b) => a - b
|
|
||||||
|
|
||||||
export default(function doSomeMath() {
|
|
||||||
return {
|
|
||||||
addTwo,
|
|
||||||
multiply,
|
|
||||||
subtract,
|
|
||||||
}
|
|
||||||
})()
|
|
Loading…
Reference in new issue