function fearNotLetter(str) {
const letters = str.split("");
const letter = letters.reduce((acc, letter, index) => {
if (acc !== undefined) return acc;
const prevLetterCode = (letters[index - 1] || letter).charCodeAt();
if (letter.charCodeAt() - prevLetterCode > 1) return String.fromCharCode(prevLetterCode + 1)
return undefined;
}, undefined);
return letter;
}
fearNotLetter("abce");
//d
class Component {
constructor(props) {
this.props = props;
}
}
import React, { Component } from 'react';
import { Collapse, Button, CardBody, Card } from 'reactstrap';
class Example extends Component {
state = {
collapse: false
};
toggle = () => {
this.setState(state => ({ collapse: !state.collapse }));
}
render() {
return (
<div>
<Button color="primary" onClick={this.toggle} style={{ marginBottom: '1rem' }}>Toggle</Button>
<Collapse isOpen={this.state.collapse}>
<Card>
<CardBody>
Anim pariatur cliche reprehenderit,
enim eiusmod high life accusamus terry richardson ad squid. Nihil
anim keffiyeh helvetica, craft beer labore wes anderson cred
nesciunt sapiente ea proident.
</CardBody>
</Card>
</Collapse>
</div>
);
}
}
export default Example;
import debounce from "lodash/debounce";
const TIME_OUT = 1000;
const handleSearch = debounce(({ target: { value } = {} }) => {
//что-то делаем
}, TIME_OUT)
$yourInput.addEventListener("input", handleSearch, false);
const data = {
"RU":[{
"name":"Русский",
"img":"/flag/RU.png",
"courses":{
"gramm":[{
"name":"Грамматика",
"img":"/icon1.png"
}],
"prav":[{
"name":"Правописание",
"img":"/icon2.png"
}]
}
}],
"EN":[{
"name":"Английский",
"img":"/flag/EN.png",
"courses":{
"gramm":[{
"name":"Грамматика",
"img":"/icon3.png"
}]
}
}]
}
const countries = [], courses = [];
$.each(data, (lng, [{ name, img, courses: crs }]) => {
countries.push([lng, name, img]);
$.each(crs, (crsName, [{ name, img }]) => {
courses.push([lng, name, img])
})
});
countries //
[
["RU", "Русский", "/flag/RU.png"],
["EN", "Английский", "/flag/EN.png"]
]
courses //
[
["RU", "Грамматика", "/icon1.png"],
["RU", "Правописание", "/icon2.png"],
["EN", "Грамматика", "/icon3.png"]
]
import { render } from './component'
export class Component {
constructor(config) {
this.template = config.template
this.selector = config.selector
this.el = null
}
render() {
this.el = document.querySelector(this.selector)
if (!this.el) throw new Error(`Component with selector <${this.selector}> wasn't found`)
this.el.innerHTML = this.template
}
}