Skip to content

Instantly share code, notes, and snippets.

View DennisDurairaj's full-sized avatar

Dennis Durairaj DennisDurairaj

View GitHub Profile
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'
let employeeSalary = function(initialSalary) {
var salary = initialSalary;
function changeBy(amount) {
salary += amount;
}
return {
raise: function() {
changeBy(5000);
},
lower: function() {
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"));
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" },
];
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" },
];
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 = () => {
...
return (
<div className="App">
{items.map(item => <div key={item.id}>{item.value}</div>)}
</div>
);
...
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">
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!" );
});
});
"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"
}