This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default function UserList({contacts}) { | |
return ( | |
<div> | |
{props.contactList.map((contact) => ( | |
<div className="card" key={contact.phonenumber}> | |
<p className="card-name">{contact.name}</p> | |
<p>{contact.email}</p> | |
<p>{contact.phonenumber}</p> | |
</div> | |
))} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useState } from "react"; | |
import ContactForm from "./components/ContactForm.jsx"; | |
import ContactList from "./components/ContactList.jsx"; | |
import "./App.css"; | |
function App() { | |
// here we create an array state to store the contact form data | |
const [contacts, updateContacts] = useState([]); | |
const addContact = (contact) => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useState } from "react"; | |
export default function UserForm({addContact}) { | |
const handleSubmit = (event) => { | |
event.preventDefault(); | |
addContact(contactInfo); | |
setContactInfo({ name: "", email: "", phonenumber: "" }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useState } from "react"; | |
import ContactForm from "./components/ContactForm.jsx"; | |
import "./App.css"; | |
function App() { | |
// here we create an array state to store the contact form data | |
const [contacts, updateContacts] = useState([]); | |
const addContact = (contactInfo) => { | |
updateContacts([...contacts, contactInfo]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useState } from "react"; | |
export default function UserForm() { | |
const [contactInfo, setContactInfo] = useState({ | |
name: "", | |
email: "", | |
phonenumber: "", | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ContactForm from "./components/ContactForm.jsx"; | |
import "./App.css"; | |
function App() { | |
return ( | |
<div className="App"> | |
<UserForm /> | |
</div> | |
); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default function UserForm() { | |
return ( | |
<div> | |
<form> | |
<div> | |
<h3>Contact Form</h3> | |
</div> | |
<div> | |
<input |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Solution using Brute Force approach */ | |
function maxProfit(prices) { | |
// set maxProfit to zero, this helps for edge case that says return zero when no profit is made | |
let maxProfit = 0 | |
// we start the buying price at index 0 to get the prices[0] | |
for(let buyPrice = 0; buyPrice < prices.length; buy++) { | |
// start sell price with buyPrice + 1 to make sure we aren't going back on the days |