123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179 |
- //**************1******************
- var color = prompt("Введите цвет", "");
- if (color == "red") {
- document.write("<div style='background-color: red;'>красный</div>");
- }
- else if (color == "black") {
- document.write("<div style='background-color: black; color: white;'>черный</div>");
- }
- else if (color == "blue") {
- document.write("<div style='background-color: blue;'>синий</div>");
- }
- else if (color == "green") {
- document.write("<div style='background-color: green;'>зеленый</div>");
- }
- else {
- document.write("<div style='background-color: gray;'>Я не понял</div>");
- }
- //**************2 and 4 and 5******************
- var age = prompt("enter your age", "");
- if (age => 0 && age <= 100) {
- alert("good work!");
- }
- else {
- alert("enter again");
- }
- alert("something");
- if (age <= 10) {
- alert("Привет сопля" + ",иди спать, детское время закончилось");
- }
- else if (age <= 20 && age > 10) {
- alert("Privet, хорошее время для прогулки");
- }
- else if (age <= 30 && age > 20) {
- alert("Приветсвую, хороший сегодня вечер");
- }
- else if (age <= 40 && age > 30) {
- alert("Здравствуйте, прекрасный вечер");
- }
- else if (age < 100 && age >= 50) {
- alert("Здравствуйте многоувожаемый старый мурдый человек, самое время для беседы");
- }
- //**************3******************
- let dec = 31, oct = 31, aug = 31, jul = 31, may = 31, march = 31, jan = 31, nov = 30, sept = 30, jun = 30, apr = 30,
- feb = 29;
- let month = prompt("choose the month");
- switch (month) {
- case "jan":
- alert("in January are " + jan + "days");
- break;
- case "feb":
- alert("in February are " + feb + "days");
- break;
- case "march":
- alert("in March are " + march + "days");
- break;
- case "apr":
- alert("in April are " + apr + "days");
- break;
- case "may":
- alert("in May are " + may + "days");
- break;
- case "jun":
- alert("in Jun are " + jun + "days");
- break;
- case "jul":
- alert("in July are " + jul + "days");
- break;
- case "aug":
- alert("in August are " + aug + "days");
- break;
- case "sept":
- alert("in September are " + sept + "days");
- break;
- case "nov":
- alert("in November are " + nov + "days");
- break;
- case "oct":
- alert("in October are " + oct + "days");
- break;
- case "dec":
- alert("in December are " + dec + "days");
- break;
- default:
- alert("try again");
- }
- //**************6******************
- var a = {
- tagName: 'body',
- subTags: b = {
- tagName: 'div',
- subTags: s = {
- tagName: 'span',
- text: 'Enter a data please'
- },
- subTags: br = {
- tagName: 'br',
- },
- subTags: input1 = {
- tagName: 'input',
- attrs: 'type=\'text\' id=\'name\''
- },
- subTags: input2 = {
- tagName: 'input',
- attrs: 'type=\'text\' id=\'surname\''
- }
- },
- subTags: c = {
- tagName: 'div',
- subTags: button1 = {
- tagName: 'button',
- text: 'OK',
- attrs: ' id=\'ok\''
- },
- subTags: button2 = {
- tagName: 'button',
- text: 'Cancel',
- attrs: ' id=\'cancel\''
- }
- }
- }
- //**************7******************
- var notebook = {
- brand: prompt("Enter a brand"),
- type: prompt("Enter a type"),
- model: prompt("Enter a model"),
- ram: prompt("Enter a ram"),
- size: prompt("Enter a size"),
- weight: prompt("Enter a weight"),
- resolution: {
- width: prompt("Enter a width"),
- height: prompt("Enter a height"),
- },
- };
- var phone = {
- brand: prompt("Enter a brand"),
- model: prompt("Enter a model"),
- ram: prompt("Enter a ram"),
- color: prompt("Enter a color"),
- };
- var person = {
- name: prompt("Enter a name"),
- surname: prompt("Enter a surname"),
- married: confirm("married?"),
- }
- //**************8******************
- do {
- var a = confirm("enter your choice");
- } while (a == false);
- //**************9******************
- let num = prompt("enter your number",);
- nextPrime:
- for (let i = 2; i <= num; i++) {
- for (let j = 2; j < i; j++) { // проверить, делится ли число..
- if (i % j == 0) continue nextPrime; // не подходит, берём следующее
- }
- alert(i); // простое число
- }
- //**************10******************
- for (let i = 0; true; i++) if (Math.random() > 0.9) {
- alert(++i);
- break;
- }
- //**************11******************
- let numb = prompt("enter number (it will chetnoe or nechotnoe)",);
- var a = '';
- for (var i = 0; i < numb; i++) {
- a += '#';
- }
- console.log(a);
- //**************12******************
- var numb = prompt("enter length of array",);
- var array = [];
- for (var i = 0; i < numb; i++) {
- array.push(Math.pow(i + 1, 3));
- }
- console.log(array);
|