This file contains hidden or 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
const survey = [ | |
{ name: "Zuri", votedFramework: 'react' }, | |
{ name: "Sofia", votedFramework: 'angular' }, | |
{ name: "Elon", votedFramework: 'react' }, | |
{ name: "Joe", votedFramework: 'react' }, | |
{ name: "Alex", votedFramework: 'angular' }, | |
{ name: "Josh", votedFramework: 'vue' }, | |
{ name: "Jade", votedFramework: 'react' }, | |
{ name: "Ted", votedFramework: 'angular' }, | |
{ name: "Leo", votedFramework: 'react' }, |
This file contains hidden or 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
const survey = [ | |
{ name: "Zuri", votedFramework: 'react' }, | |
{ name: "Sofia", votedFramework: 'angular' }, | |
{ name: "Elon", votedFramework: 'react' }, | |
{ name: "Joe", votedFramework: 'react' }, | |
{ name: "Alex", votedFramework: 'angular' }, | |
{ name: "Josh", votedFramework: 'vue' }, | |
{ name: "Jade", votedFramework: 'react' }, | |
{ name: "Ted", votedFramework: 'angular' }, | |
{ name: "Leo", votedFramework: 'react' }, |
This file contains hidden or 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
const array = [1,5,3,9,6,2,4] | |
const reducerCallback = (prevItem, currItem) => { | |
return prevItem + currItem | |
} | |
console.log(array.reduce(reducerCallback)) // 30 |
This file contains hidden or 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
const array = [ | |
{ id: 111, framework: 'react' }, | |
{ id: 222, framework: 'angular' }, | |
{ id: 333, framework: 'vue' } | |
]; | |
const reducerCallback = (prevItem, currItem) => { | |
return { | |
id: prevItem.id + currItem.id, | |
framework: prevItem.framework + "-" + currItem.framework |
This file contains hidden or 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
function getYearMonthDay(isoDateTime) { | |
const year = date.getFullYear() | |
const month = (date.getMonth() + 1 < 10 ? '0' : '') + (date.getMonth() + 1) | |
const day = date.getDate(); | |
return year + '/' + month + '/' + day | |
} | |
function getDayMonthYear(isoDateTime) { | |
const year = date.getFullYear() | |
const month = (date.getMonth() + 1 < 10 ? '0' : '') + (date.getMonth() + 1) |
This file contains hidden or 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
<button onClick={this.generateText} className="button">Generate</button> | |
... | |
{ /* Results */ } | |
<section className="results"> | |
{ this.state.documents.map((value, index) => { | |
return ( | |
<div key={index} className="results__result"> | |
<div className="results__result__image"> |
This file contains hidden or 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
generateText = () => { | |
let uploads = this.state.uploads | |
for(var i = 0; i < uploads.length; i++) { | |
Tesseract.recognize(uploads[i], { | |
lang: 'eng' | |
}) | |
.catch(err => { | |
console.error(err) | |
}) |
This file contains hidden or 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
{ /* File uploader */ } | |
<section className="hero"> | |
<label className="fileUploaderContainer"> | |
Click here to upload documents | |
<input type="file" id="fileUploader" onChange={this.handleChange} multiple /> | |
</label> | |
<div> | |
{ this.state.uploads.map((value, index) => { | |
return <img key={index} src={value} width="100px" /> |
This file contains hidden or 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
handleChange = (event) => { | |
if (event.target.files[0]) { | |
var uploads = [] | |
for (var key in event.target.files) { | |
if (!event.target.files.hasOwnProperty(key)) continue; | |
let upload = event.target.files[key] | |
uploads.push(URL.createObjectURL(upload)) | |
} | |
this.setState({ | |
uploads: uploads |
This file contains hidden or 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
constructor(props) { | |
super(props) | |
this.state = { | |
uploads: [], | |
patterns: [], | |
documents: [] | |
}; | |
} |
NewerOlder