Skip to content

Instantly share code, notes, and snippets.

@vicradon
Created October 4, 2019 07:18
Show Gist options
  • Save vicradon/658b6c9ecc582119985f7647099fb13f to your computer and use it in GitHub Desktop.
Save vicradon/658b6c9ecc582119985f7647099fb13f to your computer and use it in GitHub Desktop.
import React from "react"
import ReactDOM from "react-dom"
function App(){
let style = {
fontSize:"4rem"
}
let date = new Date(2019, 10, 4, 22);
const hours = date.getHours();
let timeOfDay = "Morning";
if (hours < 12){
timeOfDay = "Morning";
style.color = "orange";
}
else if (hours >= 12 && hours < 17){
timeOfDay = "Afternoon";
style.color = "red";
}
else{
timeOfDay = "Night";
style.color = "blue";
}
return (<h1 style = {style}>Good {timeOfDay}</h1>)
}
ReactDOM.render(<App />, document.getElementById("root"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment