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
<style> | |
#field { | |
margin: 50px; | |
width: 200px; | |
height: 150px; | |
border: 10px groove black; | |
background-color: #00FF00; | |
position: relative; | |
overflow: hidden; | |
cursor: pointer; |
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
'use strict'; | |
class Clock { | |
constructor(options) { | |
this._template = options.template; | |
} | |
start() { | |
this._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
/* Напишите функцию которая вернет самый дорогой товар и его имя */ | |
var purchases = { | |
"meat": 1200, | |
"bread": 8, | |
"child food": 230, | |
"chips": null, | |
"juice": 240 | |
}; |
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
function calc( a, b, c) { | |
if ( isNaN(a) ) { | |
console.log("Первый аргумент не число!"); | |
} | |
if ( isNaN(b) ) { | |
console.log("Второй аргумент не число!"); | |
} | |
switch (c) { |
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
/* | |
* | |
* Напишите функцию которая будет получать один параметр (число), она будет проверять этот аргумент, если он больше 18 тогда будет возвращять булевое значение true, иначе будет спрашивать confirm и вернёт результат функции confirm (желательно сделайте возможность ввода число строкой) | |
* | |
* */ | |
function checking ( number ) { | |
if ( !isNaN(number)) { | |
if ( number > 18 ) { |
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 words = [ | |
"programm", | |
"monkeys", | |
"lucky", | |
"javascript" | |
]; | |
let word = words[Math.floor(Math.random() * words.length)]; | |
let answerArray = []; | |
for(let i = 0; i < word.length; i++) { |
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
Напишите функцию camelize(str), которая преобразует строки вида «my-short-string» в «myShortString». | |
То есть, дефисы удаляются, а все слова после них получают заглавную букву. | |
----------------------------------------------------------------------------------------- | |
function camelize(str) { | |
var strNew = str.split('-'); | |
for(var i = 1; i < strNew.length; i++) { | |
strNew[i] = strNew[i].charAt(0).toUpperCase() + strNew[i].slice(1); | |
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
Создайте функцию addClass(obj, cls), которая добавляет в список класс cls, но только если его там еще нет. | |
---------------------------------------------------------------------------------------------------------- | |
function addClass(obj, cls){ | |
var allClasses = obj.className; | |
var arrClasses = allClasses.split(' '); | |
for(var i = 0; i < arrClasses.length; i++){ | |
if(arrClasses[i] === cls) { | |
return | |
} |
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
Создайте функцию filterRange(arr, a, b), которая принимает массив чисел arr и возвращает новый массив, который содержит только числа из arr из диапазона от a до b. То есть, проверка имеет вид a ≤ arr[i] ≤ b. Функция не должна менять arr. | |
---------------------------------------------------------------------------------------------- | |
var arr = [5, 4, 3, 8, 0]; | |
var filtered = filterRange(arr, 3, 5); | |
function filterRange(arr, a, b) { | |
var newArr = []; |
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
Создайте функцию find(arr, value), которая ищет в массиве arr значение value и возвращает его номер, если найдено, или -1, если не найдено. | |
----------------------------------------------------------------------------------------------------- | |
arr = ["test", 2, 1.5, false]; | |
function find(arr, val) { | |
/* 1) Первый способ */ |
NewerOlder