|
@@ -159,3 +159,63 @@ for (let i = 1, j = 1; i <= amountIteration; i++, j += 3) {
|
|
alert("Сумма арифметической прогрессии: " + sum);
|
|
alert("Сумма арифметической прогрессии: " + sum);
|
|
|
|
|
|
//chess one line
|
|
//chess one line
|
|
|
|
+let str = "";
|
|
|
|
+let strElement;
|
|
|
|
+
|
|
|
|
+for (let i = 0; i <= 10; i++) {
|
|
|
|
+
|
|
|
|
+ if ((i % 2) === 0) {
|
|
|
|
+ strElement = " ";
|
|
|
|
+ } else {
|
|
|
|
+ strElement = "#";
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ str += strElement;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+alert(str);
|
|
|
|
+
|
|
|
|
+//numbers
|
|
|
|
+let strOut = "";
|
|
|
|
+
|
|
|
|
+for (let i = 0; i < 10; i++) {
|
|
|
|
+
|
|
|
|
+ for (let j = 0; j < 10; j++) {
|
|
|
|
+ strOut += String(j);
|
|
|
|
+ }
|
|
|
|
+ strOut += "\n";
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+alert(strOut);
|
|
|
|
+
|
|
|
|
+//chess
|
|
|
|
+let chessWidth = prompt("Размер доски (ширина)");
|
|
|
|
+let chessHeight = prompt("Размер доски (высота)");
|
|
|
|
+let chess = "";
|
|
|
|
+let chessElement;
|
|
|
|
+let chess1 = ""
|
|
|
|
+
|
|
|
|
+for (let i = 0; i < chessHeight; i++) {
|
|
|
|
+
|
|
|
|
+ for (let j = 0; j < chessWidth; j++) {
|
|
|
|
+ if ((j % 2) === 0) {
|
|
|
|
+ chessElement = ".";
|
|
|
|
+ } else {
|
|
|
|
+ chessElement = "#";
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ chess += chessElement;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if ((i % 2) === 1) {
|
|
|
|
+ chess = chess.replace(/[.#]/g, c => c == '.' ? '#' : '.');
|
|
|
|
+ } else {
|
|
|
|
+ chess = chess.replace(/[.#]/g, c => c == '#' ? '.' : '#');
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ chess += "\n";
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+alert(chess);
|
|
|
|
+
|
|
|
|
+//cubes
|