const readMore = document.getElementsByClassName("hide_sub")[0];
readMore.addEventListener("click", () => {
if (readMore.textContent === "Читать полностью..") {
readMore.textContent = "Скрыть";
} else {
readMore.textContent = "Читать полностью..";
}
});
const age = person => {
let amount;
for (let i = 0; i < person.length; i++) {
for (let j = i; j < person.length; j++) {
if (person[i] > person[j]) {
amount = person[i];
person[i] = person[j];
person[j] = amount;
}
}
}
return person;
}
const res = [3, 4, 2, 78, 0, 1];
console.log(age(res));
<div class="content-area">
<h5 id="text">CONTENT AREA</h5>
<button id="hideBtn">Скрыть текст</button>
</div>
.hide-and-show {
display: none;
}
const btn = document.getElementById('hideBtn');
btn.addEventListener('click', function() {
document.getElementById('text').classList.toggle('hide-and-show');
if (btn.innerHTML === 'Показать текст') {
btn.innerHTML = 'Скрыть текст';
} else {
btn.innerHTML = 'Показать текст';
}
})
let position = 2;
class Step {
constructor(pos) {
this.step = pos;
}
run() {
console.log(this.step += 1);
}
}
const obj = new Step(position);
setInterval(obj.run.bind(obj), 1000);
const links = document.querySelectorAll('.navigation__link');
links.forEach(link => {
const btn = document.createElement('button');
btn.textContent = "BUTTON";
link.appendChild(btn);
});
const middleOfThree = (a, b, c) => (a + b + c) - (Math.min(a, b, c)) - (Math.max(a, b, c));
console.log(middleOfThree(5, 15, 20)) // 15
function user_name_is_valid(){
let response = $.ajax({
type: "POST",
url: "/api/check_username",
data: username,
dataType: 'text',
async: false
}).status;
if(response === 204){
return false;
} else if(response === 302){
return true;
}
}
setTImeout(function() {
if (!user_name_is_valid()){
alert("username is invalid!");
}
}, 3000)
const asyncVar = setTimeout(user_name_is_valid, 3000);
function user_name_is_valid() {
let response = $.ajax({
type: "POST",
url: "/api/check_username",
data: username,
dataType: 'text',
async: false
}).status;
if(response === 204){
return false;
} else if(response === 302){
return true;
}
}
if (!asyncVar){
alert("username is invalid!");
}
let box = document.getElement s ByClassName('box-text1')[0];
let box = document.getElementsByClassName('box-text1')[0];
let box = document.getElementById('box-text1')[0];