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, { Component } from "react"; | |
import { render } from "react-dom"; | |
class App extends Component { | |
state = { | |
data: [] | |
}; | |
componentDidMount() { | |
this.getDataFromApi(); |
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, { Component } from "react"; | |
import { render } from "react-dom"; | |
import cheerio from "cheerio"; | |
import renderHTML from "react-render-html"; | |
class App extends Component { | |
state = { | |
data: [], | |
logos: [] | |
}; |
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
class App extends React.Component { | |
constructor(props) { | |
super(props); | |
this.state = { message: "Hello World!" }; | |
} | |
logMessage() { | |
console.log(this.state.message); | |
} |
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
class App extends React.Component { | |
constructor(props) { | |
super(props); | |
this.state = { message: "Hello World!" }; | |
} | |
logMessage() { | |
console.log(this.state.message); | |
} |
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
class App extends React.Component { | |
state = { | |
message: 'Hello World!' | |
}; | |
logMessage = () => { | |
console.log(this.state.message); | |
} | |
render() { |
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
class App extends React.Component { | |
constructor(props) { | |
super(props); | |
this.state = { message: "Hello World!" }; | |
this.logMessage = this.logMessage.bind(this); | |
} | |
logMessage = () => { | |
console.log(this.state.message); | |
} |
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
var colors = ['red', 'yellow', 'purple']; | |
colors.forEach(function(color) { | |
console.log(color); | |
}); |
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 howMany = 4; | |
if(howMany > 3){ | |
let displayApples = "I have more than 3 apples"; | |
console.log(displayApples); // "I have more than 3 apples" | |
} | |
console.log(displayApples); // displayApples is not defined |
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
// This is OK - updating apples | |
let apples = "3 apples"; | |
apples = "4 apples"; | |
// This is NOT OK - re-declare pears | |
let pears = "3 pears"; | |
let pears = "4 pears"; // error: Identifier 'pears' has already been declared | |
// This is OK - different scopes, same variable name | |
let bananas = "3 bananas"; |
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
var applesInBaskets = [32, 33, 16, 40]; | |
var pearsInBaskets = [32, 33, 39, 40]; | |
var bananasInBaskets = [6, 10, 12, 17]; | |
function checkBasket(basket) { | |
return basket >= 20; | |
} | |
// All baskets in array should have more than 20 fruits to return TRUE | |
console.log(applesInBaskets.every(checkBasket)); // false - one basket with apples has less than 20 apples (16) |
OlderNewer