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
let a = 'global scope'; | |
function outer() { | |
let b = 'outer scope'; | |
function inner() { | |
let c = 'inner scope' | |
console.log(c); // Output: 'inner scope' | |
console.log(b); // Output: 'outer scope' | |
console.log(a); // Output: 'global scope' | |
} | |
console.log(a); // Output: 'global scope' |
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
let employeeSalary = function(initialSalary) { | |
var salary = initialSalary; | |
function changeBy(amount) { | |
salary += amount; | |
} | |
return { | |
raise: function() { | |
changeBy(5000); | |
}, | |
lower: function() { |
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 React from "react"; | |
import ReactDOM from "react-dom"; | |
import "./index.css"; | |
import App from "./App"; | |
import ShuffleFocus from "./ShuffleFocus"; | |
ReactDOM.render(<ShuffleFocus />, document.getElementById("root")); |
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 React, { useState, useEffect } from "react"; | |
import "./App.css"; | |
const ShuffleFocus = () => { | |
const [items, setItems] = useState([]); | |
const itemList = [ | |
{ id: 1, value: "London" }, | |
{ id: 2, value: "Paris" }, | |
{ id: 3, value: "Tokyo" }, | |
{ id: 4, value: "Berlin" }, | |
]; |
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 React, { useState } from "react"; | |
import "./App.css"; | |
function App() { | |
const [items, setItems] = useState([]); | |
const itemList = [ | |
{ id: 1, value: "London" }, | |
{ id: 2, value: "Paris" }, | |
{ id: 3, value: "Tokyo" }, | |
{ id: 4, value: "Berlin" }, | |
]; |
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 React, { useState } from "react"; | |
import "./App.css"; | |
function App() { | |
const [items, setItems] = useState([]); | |
const itemList = [ { id: 1, value: "London" }, | |
{ id: 2, value: "Paris" }, | |
{ id: 3, value: "Tokyo" }, | |
{ id: 4, value: "Berlin" } ]; | |
const addItem = () => { |
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
... | |
return ( | |
<div className="App"> | |
{items.map(item => <div key={item.id}>{item.value}</div>)} | |
</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 React from "react"; | |
import "./App.css"; | |
function App() { | |
const items = [{ id: 1, value: "London" }, | |
{ id: 2, value: "Paris" }, | |
{ id: 3, value: "Tokyo" }, | |
{ id: 4, value: "Berlin" }]; | |
return ( | |
<div className="App"> |
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
describe("Testing Fetching Weather Forecast", () => { | |
it("Searches weather for invalid city", () => { | |
cy.visit("http://localhost:3000"); | |
cy.get("[data-cy='cityName']").type("Chicago"); | |
cy.get("[data-cy='submitCity']").click(); | |
cy.get("[data-cy='notFound']").contains( "Sorry! City does not exist in database!" ); | |
}); | |
}); |
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
"scripts": { | |
"mockAPI": "npx json-server db.json --port 3050 --watch", | |
"start": "concurrently \"npm run mockAPI\" \"react-scripts start\"", | |
"build": "react-scripts build", | |
"test": "react-scripts test", | |
"eject": "react-scripts eject", | |
"e2e-test": "./node_modules/.bin/cypress run", | |
"cypress:open": "./node_modules/.bin/cypress open" | |
} |
NewerOlder