{"id":329874,"date":"2022-02-20T09:00:20","date_gmt":"2022-02-20T09:00:20","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=329874"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=329874","title":{"rendered":"<span>\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 lorem ipsum \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440 \u043d\u0430 JavaScript<\/span>"},"content":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0413\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044f \u043a\u043e\u043d\u0442\u0435\u043d\u0442\u0430 \u0438\u0437 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0445 \u0441\u043b\u043e\u0432 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043e\u0447\u0435\u043d\u044c \u043f\u043e\u043b\u0435\u0437\u043d\u0430 \u0434\u043b\u044f \u043a\u0430\u043a\u0438\u0445-\u043b\u0438\u0431\u043e \u0442\u0435\u0441\u0442\u043e\u0432. \u0412\u043e\u0442 \u043f\u043e\u0447\u0435\u043c\u0443 \u0441\u0435\u0433\u043e\u0434\u043d\u044f \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u044d\u0442\u043e \u0434\u0435\u043b\u0430\u0442\u044c.<\/p>\n<p>\u0411\u0435\u0437\u0443\u0441\u043b\u043e\u0432\u043d\u043e, \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u0430\u043a\u0443\u044e-\u043d\u0438\u0431\u0443\u0434\u044c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443, \u043d\u043e, \u0442\u0430\u043a \u043a\u0430\u043a \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0442\u0430\u043a\u043e\u0439 \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u043d\u0435 \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u0441\u043b\u043e\u0436\u043d\u043e \u0438 \u043d\u0435 \u0437\u0430\u0439\u043c\u0435\u0442 \u043c\u043d\u043e\u0433\u043e \u0441\u0442\u0440\u043e\u043a \u043a\u043e\u0434\u0430, \u0431\u044b\u043b\u043e \u0431\u044b \u043d\u0435\u043f\u043b\u043e\u0445\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0435\u0435 \u0441\u0430\u043c\u043e\u043c\u0443. <\/p>\n<p>\u0414\u043b\u044f \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u043a\u043e\u043d\u0442\u0435\u043d\u0442\u0430 \u043d\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u044f\u0442\u0441\u044f \u0442\u0440\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a \u0441\u0430\u043c\u0438\u0445 \u0441\u043b\u043e\u0432:<\/p>\n<ol>\n<li>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u044f, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0449\u0430\u044f \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e.<\/p>\n<\/li>\n<li>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043d\u0430\u043c \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0435 \u0441\u043b\u043e\u0432\u043e.<\/p>\n<\/li>\n<li>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0434\u0435\u043b\u0430\u0435\u0442 \u0438\u0437 \u0441\u043b\u043e\u0432 \u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u0443\u044e \u0441\u0442\u0440\u043e\u043a\u0443.<\/p>\n<\/li>\n<li>\n<p>\u0418\u0441\u0442\u043e\u0447\u043d\u0438\u043a \u0441\u043b\u043e\u0432 \u0432 \u0432\u0438\u0434\u0435 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u0441\u0442\u0440\u043e\u043a (<a href=\"https:\/\/gist.github.com\/devbyray\/8dbac8a32c7c87f659d9b34137e25ba0\" rel=\"noopener noreferrer nofollow\">\u043c\u043e\u0436\u043d\u043e \u0432\u0437\u044f\u0442\u044c \u0438\u0437 \u043c\u043e\u0435\u0433\u043e Github Gist<\/a>).<\/p>\n<\/li>\n<\/ol>\n<hr\/>\n<h3>1. \u0413\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044f \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0433\u043e \u0447\u0438\u0441\u043b\u0430<\/h3>\n<p>\u0422\u0430\u043a \u043a\u0430\u043a \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0435 \u0441\u043b\u043e\u0432\u043e \u0438\u0437 \u043d\u0430\u0448\u0435\u0433\u043e \u043c\u0430\u0441\u0441\u0438\u0432\u0430, \u043d\u0430\u043c \u043d\u0430\u0434\u043e \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0439 \u0438\u043d\u0434\u0435\u043a\u0441. \u0421 \u0443\u0447\u0435\u0442\u043e\u043c \u044d\u0442\u043e\u0433\u043e, \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u043f\u043e\u043c\u043d\u0438\u0442\u044c \u043e \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u043c \u0438 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0438 \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u043c\u0430\u0441\u0441\u0438\u0432\u0430.<\/p>\n<pre><code class=\"javascript\">Math.random(); \/\/ Returns 0.534098468876492<\/code><\/pre>\n<p>\u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>Math.random()<\/code> \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0434\u0440\u043e\u0431\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u043e\u0442 0 \u0434\u043e 1 (\u043d\u0435 \u0432\u043a\u043b\u044e\u0447\u0430\u044f 1). \u041a\u043e\u0433\u0434\u0430 \u043c\u044b \u0443\u043c\u043d\u043e\u0436\u0430\u0435\u043c \u0435\u0433\u043e, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043d\u0430 10, \u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0447\u0438\u0441\u043b\u043e \u043e\u0442 0 \u0434\u043e 10 (\u0442\u0430\u043a\u0436\u0435 \u043d\u0435 \u0432\u043a\u043b\u044e\u0447\u0430\u044f \u0432\u0435\u0440\u0445\u043d\u044e\u044e \u0433\u0440\u0430\u043d\u0438\u0446\u0443). \u041d\u043e \u0432 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u043d\u0430\u043c \u0445\u043e\u0447\u0435\u0442\u0441\u044f \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0447\u0438\u0441\u043b\u043e \u043e\u0442 0 \u0434\u043e 10, \u0432\u043a\u043b\u044e\u0447\u0430\u044f \u0432\u0435\u0440\u0445\u043d\u044e\u044e \u0433\u0440\u0430\u043d\u0438\u0446\u0443.<\/p>\n<pre><code class=\"javascript\">Math.random() * (10 - 0) + 0; \/\/ Returns 8.448742196214798<\/code><\/pre>\n<p>\u041d\u043e \u0441\u0435\u0439\u0447\u0430\u0441 \u043c\u044b \u0432\u0441\u0435 \u0435\u0449\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0434\u0440\u043e\u0431\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e. \u041c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <code>Math.round<\/code>, \u0447\u0442\u043e\u0431\u044b \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0435\u0433\u043e \u0446\u0435\u043b\u044b\u043c.<\/p>\n<pre><code class=\"javascript\">Math.round(Math.random() * (10 - 0) + 0) \/\/ Returns 6 or 5 or 9 or 10<\/code><\/pre>\n<p>\u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u044d\u0442\u0438\u043c \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f\u043c \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0446\u0435\u043b\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u043e\u0442 0 \u0434\u043e 10, \u0432\u043a\u043b\u044e\u0447\u0430\u044f \u043e\u0431\u0435 \u0433\u0440\u0430\u043d\u0438\u0446\u044b. \u0412\u044b \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u0440\u043e\u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u043e\u0442 \u043a\u043e\u0434.<\/p>\n<pre><code class=\"javascript\">let number = 0; let steps = 0; while(number != 10) {     number = Math.round(Math.random() * (10 - 0) + 0);     steps = steps + 1;     console.log('steps', steps) }<\/code><\/pre>\n<p>\u0417\u0434\u0435\u0441\u044c \u0432\u044b \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0435 \u0446\u0438\u043a\u043b \u0434\u043e \u0442\u043e\u0433\u043e \u043c\u043e\u043c\u0435\u043d\u0442\u0430, \u043f\u043e\u043a\u0430 \u0447\u0438\u0441\u043b\u043e \u043d\u0435 \u0441\u0442\u0430\u043d\u0435\u0442 \u0440\u0430\u0432\u043d\u044b\u043c 10. \u041e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u044f \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0439, \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0441\u043a\u0430\u0437\u0430\u0442\u044c, \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0438\u0445 \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u043b\u043e\u0441\u044c. \u0415\u0441\u043b\u0438 \u0432\u044b \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u0435 \u044d\u0442\u043e\u0442 \u043a\u043e\u0434 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0437, \u0442\u043e \u043f\u043e\u0439\u043c\u0435\u0442\u0435, \u0447\u0442\u043e \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u0440\u043e\u0445\u043e\u0434\u043e\u0432 \u043f\u043e \u0446\u0438\u043a\u043b\u0443 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0437\u043d\u044b\u043c.<\/p>\n<pre><code class=\"javascript\">function randomNumber(min, max) {     return Math.round(Math.random() * (max - min) + min); }<\/code><\/pre>\n<p>\u042d\u0442\u043e \u0444\u0438\u043d\u0430\u043b\u044c\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0433\u043e \u0447\u0438\u0441\u043b\u0430 \u0432 \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u0435. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u043c \u0438 \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0433\u043e \u0441\u043b\u043e\u0432\u0430 \u0438\u0437 \u043c\u0430\u0441\u0441\u0438\u0432\u0430.<\/p>\n<hr\/>\n<h3>2. \u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0433\u043e \u0441\u043b\u043e\u0432\u0430<\/h3>\n<p>\u042f \u043d\u0430\u0448\u0435\u043b \u0445\u043e\u0440\u043e\u0448\u0443\u044e \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044e \u0441\u043b\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c. \u0412\u044b \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u0435\u0442\u0435 \u043d\u0430\u0439\u0442\u0438 \u0435\u0435 \u043d\u0430 <a href=\"https:\/\/gist.github.com\/devbyray\/8dbac8a32c7c87f659d9b34137e25ba0\" rel=\"noopener noreferrer nofollow\">Github Gist<\/a>. \u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u0431\u0443\u0434\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043b\u0438\u0448\u044c \u0447\u0430\u0441\u0442\u044c.<\/p>\n<pre><code class=\"javascript\">const word = [     \"Got\",     \"ability\",     \"shop\",     \"recall\",     \"fruit\",     \"easy\",     \"dirty\",     \"giant\",     \"shaking\",     \"ground\",     \"weather\",     \"lesson\",     \"almost\",     \"square\",     \"forward\",     \"bend\",     \"cold\",     \"broken\",     \"distant\",     \"adjective.\" ]<\/code><\/pre>\n<p>\u0411\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <code>randomNumber<\/code>\u00a0\u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u044b \u0441\u0434\u0435\u043b\u0430\u043b\u0438 \u043d\u0430 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u043c \u0448\u0430\u0433\u0435. \u0414\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0433\u043e \u0447\u0438\u0441\u043b\u0430 \u043d\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0437\u0430\u0434\u0430\u0442\u044c \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c.<\/p>\n<pre><code class=\"javascript\">const word = words[randomNumber(0, words.length - 1)];<\/code><\/pre>\n<p>\u041d\u0438\u0436\u043d\u044f\u044f \u0433\u0440\u0430\u043d\u0438\u0446\u0430 \u044d\u0442\u043e 0, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u044b \u0432 \u043c\u0430\u0441\u0441\u0438\u0432\u0430\u0445 \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0442\u0441\u044f \u0441 0. \u0412\u0435\u0440\u0445\u043d\u044f\u044f \u0433\u0440\u0430\u043d\u0438\u0446\u0430 \u043b\u0435\u0433\u043a\u043e \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u0442\u0441\u044f \u043a\u0430\u043a<code>words.length - 1<\/code> . \u041c\u044b \u0437\u0430\u0434\u0430\u0435\u043c \u0435\u0435 \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0432 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0432 \u043c\u0430\u0441\u0441\u0438\u0432\u0435 \u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f 20 \u0441\u043b\u043e\u0432, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 <code>words.length<\/code> \u0432\u0435\u0440\u043d\u0435\u0442 20. \u041d\u043e \u043f\u043e \u0440\u0430\u043d\u0435\u0435 \u0443\u043f\u043e\u043c\u044f\u043d\u0443\u0442\u043e\u0439 \u043f\u0440\u0438\u0447\u0438\u043d\u0435 (\u0438\u043d\u0434\u0435\u043a\u0441\u044b \u0432 \u043c\u0430\u0441\u0441\u0438\u0432\u0435 \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0442\u0441\u044f \u0441 0), \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0438\u043d\u0434\u0435\u043a\u0441 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043e\u0442\u043d\u044f\u0442\u044c 1.<\/p>\n<pre><code class=\"javascript\">function getRandomWord() {     return words[randomNumber(0, words.length - 1)]; }<\/code><\/pre>\n<p>\u0418\u0442\u0430\u043a, \u043c\u044b \u0438\u043c\u0435\u0435\u0442 \u0432\u0442\u043e\u0440\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0435 \u0441\u043b\u043e\u0432\u043e.<\/p>\n<hr\/>\n<h3>3. \u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0441\u0442\u0440\u043e\u043a\u0438 \u0441\u043e \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u043c\u0438 \u0441\u043b\u043e\u0432\u0430\u043c\u0438<\/h3>\n<p>\u0421\u0435\u0439\u0447\u0430\u0441 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u043b\u043e\u0432 \u0438 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0438\u0437 \u043d\u0438\u0445 \u0441\u0442\u0440\u043e\u043a\u0443. \u041b\u0443\u0447\u0448\u0438\u043c \u0440\u0435\u0448\u0435\u043d\u0438\u0435\u043c \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043c\u0430\u0441\u0441\u0438\u0432 \u0438\u0437 10 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432.<\/p>\n<pre><code class=\"javascript\">[...Array(10)] \/\/ Returns [undefined, undefined, ....] with 10 items<\/code><\/pre>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f <code>.map<\/code>\u00a0\u043c\u0435\u0442\u043e\u0434, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u0440\u043e\u0439\u0442\u0438\u0441\u044c \u043f\u043e \u043c\u0430\u0441\u0441\u0438\u0432\u0443 \u0438 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0435 \u0441\u043b\u043e\u0432\u043e.<\/p>\n<pre><code class=\"javascript\">[...Array(10)].map(() => getRandomWord()) \/\/ Returns [\"hand\", \"close\", \"ship\", \"possibly\", \"metal\", \"myself\", \"everybody\", \"serious\", \"adult\", \"favorite\"]<\/code><\/pre>\n<p>\u0412 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u043e \u043c\u0430\u0441\u0441\u0438\u0432 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0445 \u0441\u043b\u043e\u0432, \u043d\u043e \u0447\u0442\u043e\u0431\u044b \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0435\u0433\u043e \u0441\u0442\u0440\u043e\u043a\u043e\u0439, \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0442\u044c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u043f\u0440\u043e\u0431\u0435\u043b\u043e\u043c. \u042d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434\u043e\u043c <code>.join('')<\/code>.  <\/p>\n<pre><code class=\"javascript\">[...Array(10)].map(() => getRandomWord()).join('')<\/code><\/pre>\n<p>\u0422\u0430\u043a\u0436\u0435 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0447\u0438\u0442\u0430\u0431\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u043d\u0430\u0448\u0435\u0439 \u0441\u0442\u0440\u043e\u043a\u0435, \u0430 \u0438\u043c\u0435\u043d\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043f\u0435\u0440\u0432\u043e\u0435 \u0441\u043b\u043e\u0432\u043e \u0441 \u0437\u0430\u0433\u043b\u0430\u0432\u043d\u043e\u0439 \u0431\u0443\u043a\u0432\u044b. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043e\u0431\u043d\u043e\u0432\u0438\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e <code>getRandomWord<\/code>\u00a0.<\/p>\n<pre><code class=\"javascript\">function getRandomWord(firstLetterToUppercase = false) {     const word = words[randomNumber(0, words.length - 1)];     return firstLetterToUppercase ? word.charAt(0).toUpperCase() + word.slice(1) : word; }<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e <code>generateWords<\/code> . \u0422\u0435\u043f\u0435\u0440\u044c \u0432\u00a0<code>getRandomWord(i === 0)<\/code> \u0431\u0443\u0434\u0435\u043c \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u0441 0, \u0447\u0442\u043e\u0431\u044b \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043f\u0435\u0440\u0432\u043e\u0435 \u0441\u043b\u043e\u0432\u043e (\u0447\u0435\u0439 \u0438\u043d\u0434\u0435\u043a\u0441 \u043a\u0430\u043a \u0440\u0430\u0437 \u0440\u0430\u0432\u0435\u043d 0) \u0437\u0430\u0433\u043b\u0430\u0432\u043d\u044b\u043c.<\/p>\n<pre><code class=\"javascript\">function generateWords(length = 10) {     return [...Array(length)].map((_, i) => getRandomWord(i === 0)).join(' ').trim() + '.'; }<\/code><\/pre>\n<hr\/>\n<h3>4. \u0417\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u0435<\/h3>\n<p>\u041c\u044b \u043d\u0430\u043f\u0438\u0441\u0430\u043b\u0438 \u0432\u0441\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u0442\u0430\u043a \u0447\u0442\u043e \u043c\u043e\u0436\u0435\u043c \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043d\u0430 \u0432\u0435\u0441\u044c \u043a\u043e\u0434.<\/p>\n<pre><code class=\"javascript\">const word = [     \"Got\",     \"ability\",     \"shop\",     \"recall\",     \"fruit\",     \"easy\",     \"dirty\",     \"giant\",     \"shaking\",     \"ground\",     \"weather\",     \"lesson\",     \"almost\",     \"square\",     \"forward\",     \"bend\",     \"cold\",     \"broken\",     \"distant\",     \"adjective.\" ] function getRandomWord(firstLetterToUppercase = false) {     const word = words[randomNumber(0, words.length - 1)];     return firstLetterToUppercase ? word.charAt(0).toUpperCase() + word.slice(1) : word; } function generateWords(length = 10) {     return [...Array(length)].map((_, i) => getRandomWord(i === 0)).join(' ').trim() + '.'; } function randomNumber(min, max) {     return Math.round(Math.random() * (max - min) + min); }<\/code><\/pre>\n<p>\u041f\u0440\u043e\u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u043d\u0430 <a href=\"https:\/\/runkit.com\/devbyrayray\/how-to-generate-a-string-with-random-words\" rel=\"noopener noreferrer nofollow\">Runkit<\/a>.<\/p>\n<p>\u0421\u043f\u0430\u0441\u0438\u0431\u043e \u0437\u0430 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435.<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"v-portal\" style=\"display:none;\"><\/div>\n<\/div>\n<p> <!----> <!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/652531\/\"> https:\/\/habr.com\/ru\/post\/652531\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0413\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044f \u043a\u043e\u043d\u0442\u0435\u043d\u0442\u0430 \u0438\u0437 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0445 \u0441\u043b\u043e\u0432 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043e\u0447\u0435\u043d\u044c \u043f\u043e\u043b\u0435\u0437\u043d\u0430 \u0434\u043b\u044f \u043a\u0430\u043a\u0438\u0445-\u043b\u0438\u0431\u043e \u0442\u0435\u0441\u0442\u043e\u0432. \u0412\u043e\u0442 \u043f\u043e\u0447\u0435\u043c\u0443 \u0441\u0435\u0433\u043e\u0434\u043d\u044f \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u044d\u0442\u043e \u0434\u0435\u043b\u0430\u0442\u044c.<\/p>\n<p>\u0411\u0435\u0437\u0443\u0441\u043b\u043e\u0432\u043d\u043e, \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u0430\u043a\u0443\u044e-\u043d\u0438\u0431\u0443\u0434\u044c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443, \u043d\u043e, \u0442\u0430\u043a \u043a\u0430\u043a \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0442\u0430\u043a\u043e\u0439 \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u043d\u0435 \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u0441\u043b\u043e\u0436\u043d\u043e \u0438 \u043d\u0435 \u0437\u0430\u0439\u043c\u0435\u0442 \u043c\u043d\u043e\u0433\u043e \u0441\u0442\u0440\u043e\u043a \u043a\u043e\u0434\u0430, \u0431\u044b\u043b\u043e \u0431\u044b \u043d\u0435\u043f\u043b\u043e\u0445\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0435\u0435 \u0441\u0430\u043c\u043e\u043c\u0443. <\/p>\n<p>\u0414\u043b\u044f \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u043a\u043e\u043d\u0442\u0435\u043d\u0442\u0430 \u043d\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u044f\u0442\u0441\u044f \u0442\u0440\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a \u0441\u0430\u043c\u0438\u0445 \u0441\u043b\u043e\u0432:<\/p>\n<ol>\n<li>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u044f, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0449\u0430\u044f \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e.<\/p>\n<\/li>\n<li>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043d\u0430\u043c \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0435 \u0441\u043b\u043e\u0432\u043e.<\/p>\n<\/li>\n<li>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0434\u0435\u043b\u0430\u0435\u0442 \u0438\u0437 \u0441\u043b\u043e\u0432 \u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u0443\u044e \u0441\u0442\u0440\u043e\u043a\u0443.<\/p>\n<\/li>\n<li>\n<p>\u0418\u0441\u0442\u043e\u0447\u043d\u0438\u043a \u0441\u043b\u043e\u0432 \u0432 \u0432\u0438\u0434\u0435 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u0441\u0442\u0440\u043e\u043a (<a href=\"https:\/\/gist.github.com\/devbyray\/8dbac8a32c7c87f659d9b34137e25ba0\" rel=\"noopener noreferrer nofollow\">\u043c\u043e\u0436\u043d\u043e \u0432\u0437\u044f\u0442\u044c \u0438\u0437 \u043c\u043e\u0435\u0433\u043e Github Gist<\/a>).<\/p>\n<\/li>\n<\/ol>\n<hr\/>\n<h3>1. \u0413\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044f \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0433\u043e \u0447\u0438\u0441\u043b\u0430<\/h3>\n<p>\u0422\u0430\u043a \u043a\u0430\u043a \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0435 \u0441\u043b\u043e\u0432\u043e \u0438\u0437 \u043d\u0430\u0448\u0435\u0433\u043e \u043c\u0430\u0441\u0441\u0438\u0432\u0430, \u043d\u0430\u043c \u043d\u0430\u0434\u043e \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0439 \u0438\u043d\u0434\u0435\u043a\u0441. \u0421 \u0443\u0447\u0435\u0442\u043e\u043c \u044d\u0442\u043e\u0433\u043e, \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u043f\u043e\u043c\u043d\u0438\u0442\u044c \u043e \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u043c \u0438 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0438 \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u043c\u0430\u0441\u0441\u0438\u0432\u0430.<\/p>\n<pre><code class=\"javascript\">Math.random(); \/\/ Returns 0.534098468876492<\/code><\/pre>\n<p>\u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>Math.random()<\/code> \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0434\u0440\u043e\u0431\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u043e\u0442 0 \u0434\u043e 1 (\u043d\u0435 \u0432\u043a\u043b\u044e\u0447\u0430\u044f 1). \u041a\u043e\u0433\u0434\u0430 \u043c\u044b \u0443\u043c\u043d\u043e\u0436\u0430\u0435\u043c \u0435\u0433\u043e, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043d\u0430 10, \u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0447\u0438\u0441\u043b\u043e \u043e\u0442 0 \u0434\u043e 10 (\u0442\u0430\u043a\u0436\u0435 \u043d\u0435 \u0432\u043a\u043b\u044e\u0447\u0430\u044f \u0432\u0435\u0440\u0445\u043d\u044e\u044e \u0433\u0440\u0430\u043d\u0438\u0446\u0443). \u041d\u043e \u0432 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u043d\u0430\u043c \u0445\u043e\u0447\u0435\u0442\u0441\u044f \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0447\u0438\u0441\u043b\u043e \u043e\u0442 0 \u0434\u043e 10, \u0432\u043a\u043b\u044e\u0447\u0430\u044f \u0432\u0435\u0440\u0445\u043d\u044e\u044e \u0433\u0440\u0430\u043d\u0438\u0446\u0443.<\/p>\n<pre><code class=\"javascript\">Math.random() * (10 - 0) + 0; \/\/ Returns 8.448742196214798<\/code><\/pre>\n<p>\u041d\u043e \u0441\u0435\u0439\u0447\u0430\u0441 \u043c\u044b \u0432\u0441\u0435 \u0435\u0449\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0434\u0440\u043e\u0431\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e. \u041c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <code>Math.round<\/code>, \u0447\u0442\u043e\u0431\u044b \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0435\u0433\u043e \u0446\u0435\u043b\u044b\u043c.<\/p>\n<pre><code class=\"javascript\">Math.round(Math.random() * (10 - 0) + 0) \/\/ Returns 6 or 5 or 9 or 10<\/code><\/pre>\n<p>\u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u044d\u0442\u0438\u043c \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f\u043c \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0446\u0435\u043b\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u043e\u0442 0 \u0434\u043e 10, \u0432\u043a\u043b\u044e\u0447\u0430\u044f \u043e\u0431\u0435 \u0433\u0440\u0430\u043d\u0438\u0446\u044b. \u0412\u044b \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u0440\u043e\u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u043e\u0442 \u043a\u043e\u0434.<\/p>\n<pre><code class=\"javascript\">let number = 0; let steps = 0; while(number != 10) {     number = Math.round(Math.random() * (10 - 0) + 0);     steps = steps + 1;     console.log('steps', steps) }<\/code><\/pre>\n<p>\u0417\u0434\u0435\u0441\u044c \u0432\u044b \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0435 \u0446\u0438\u043a\u043b \u0434\u043e \u0442\u043e\u0433\u043e \u043c\u043e\u043c\u0435\u043d\u0442\u0430, \u043f\u043e\u043a\u0430 \u0447\u0438\u0441\u043b\u043e \u043d\u0435 \u0441\u0442\u0430\u043d\u0435\u0442 \u0440\u0430\u0432\u043d\u044b\u043c 10. \u041e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u044f \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0439, \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0441\u043a\u0430\u0437\u0430\u0442\u044c, \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0438\u0445 \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u043b\u043e\u0441\u044c. \u0415\u0441\u043b\u0438 \u0432\u044b \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u0435 \u044d\u0442\u043e\u0442 \u043a\u043e\u0434 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0437, \u0442\u043e \u043f\u043e\u0439\u043c\u0435\u0442\u0435, \u0447\u0442\u043e \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u0440\u043e\u0445\u043e\u0434\u043e\u0432 \u043f\u043e \u0446\u0438\u043a\u043b\u0443 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0437\u043d\u044b\u043c.<\/p>\n<pre><code class=\"javascript\">function randomNumber(min, max) {     return Math.round(Math.random() * (max - min) + min); }<\/code><\/pre>\n<p>\u042d\u0442\u043e \u0444\u0438\u043d\u0430\u043b\u044c\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0433\u043e \u0447\u0438\u0441\u043b\u0430 \u0432 \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u0435. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u043c \u0438 \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0433\u043e \u0441\u043b\u043e\u0432\u0430 \u0438\u0437 \u043c\u0430\u0441\u0441\u0438\u0432\u0430.<\/p>\n<hr\/>\n<h3>2. \u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0433\u043e \u0441\u043b\u043e\u0432\u0430<\/h3>\n<p>\u042f \u043d\u0430\u0448\u0435\u043b \u0445\u043e\u0440\u043e\u0448\u0443\u044e \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044e \u0441\u043b\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c. \u0412\u044b \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u0435\u0442\u0435 \u043d\u0430\u0439\u0442\u0438 \u0435\u0435 \u043d\u0430 <a href=\"https:\/\/gist.github.com\/devbyray\/8dbac8a32c7c87f659d9b34137e25ba0\" rel=\"noopener noreferrer nofollow\">Github Gist<\/a>. \u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u0431\u0443\u0434\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043b\u0438\u0448\u044c \u0447\u0430\u0441\u0442\u044c.<\/p>\n<pre><code class=\"javascript\">const word = [     \"Got\",     \"ability\",     \"shop\",     \"recall\",     \"fruit\",     \"easy\",     \"dirty\",     \"giant\",     \"shaking\",     \"ground\",     \"weather\",     \"lesson\",     \"almost\",     \"square\",     \"forward\",     \"bend\",     \"cold\",     \"broken\",     \"distant\",     \"adjective.\" ]<\/code><\/pre>\n<p>\u0411\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <code>randomNumber<\/code>\u00a0\u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u044b \u0441\u0434\u0435\u043b\u0430\u043b\u0438 \u043d\u0430 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u043c \u0448\u0430\u0433\u0435. \u0414\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0433\u043e \u0447\u0438\u0441\u043b\u0430 \u043d\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0437\u0430\u0434\u0430\u0442\u044c \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c.<\/p>\n<pre><code class=\"javascript\">const word = words[randomNumber(0, words.length - 1)];<\/code><\/pre>\n<p>\u041d\u0438\u0436\u043d\u044f\u044f \u0433\u0440\u0430\u043d\u0438\u0446\u0430 \u044d\u0442\u043e 0, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u044b \u0432 \u043c\u0430\u0441\u0441\u0438\u0432\u0430\u0445 \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0442\u0441\u044f \u0441 0. \u0412\u0435\u0440\u0445\u043d\u044f\u044f \u0433\u0440\u0430\u043d\u0438\u0446\u0430 \u043b\u0435\u0433\u043a\u043e \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u0442\u0441\u044f \u043a\u0430\u043a<code>words.length - 1<\/code> . \u041c\u044b \u0437\u0430\u0434\u0430\u0435\u043c \u0435\u0435 \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0432 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0432 \u043c\u0430\u0441\u0441\u0438\u0432\u0435 \u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f 20 \u0441\u043b\u043e\u0432, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 <code>words.length<\/code> \u0432\u0435\u0440\u043d\u0435\u0442 20. \u041d\u043e \u043f\u043e \u0440\u0430\u043d\u0435\u0435 \u0443\u043f\u043e\u043c\u044f\u043d\u0443\u0442\u043e\u0439 \u043f\u0440\u0438\u0447\u0438\u043d\u0435 (\u0438\u043d\u0434\u0435\u043a\u0441\u044b \u0432 \u043c\u0430\u0441\u0441\u0438\u0432\u0435 \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0442\u0441\u044f \u0441 0), \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0438\u043d\u0434\u0435\u043a\u0441 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043e\u0442\u043d\u044f\u0442\u044c 1.<\/p>\n<pre><code class=\"javascript\">function getRandomWord() {     return words[randomNumber(0, words.length - 1)]; }<\/code><\/pre>\n<p>\u0418\u0442\u0430\u043a, \u043c\u044b \u0438\u043c\u0435\u0435\u0442 \u0432\u0442\u043e\u0440\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0435 \u0441\u043b\u043e\u0432\u043e.<\/p>\n<hr\/>\n<h3>3. \u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0441\u0442\u0440\u043e\u043a\u0438 \u0441\u043e \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u043c\u0438 \u0441\u043b\u043e\u0432\u0430\u043c\u0438<\/h3>\n<p>\u0421\u0435\u0439\u0447\u0430\u0441 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u043b\u043e\u0432 \u0438 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0438\u0437 \u043d\u0438\u0445 \u0441\u0442\u0440\u043e\u043a\u0443. \u041b\u0443\u0447\u0448\u0438\u043c \u0440\u0435\u0448\u0435\u043d\u0438\u0435\u043c \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043c\u0430\u0441\u0441\u0438\u0432 \u0438\u0437 10 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432.<\/p>\n<pre><code class=\"javascript\">[...Array(10)] \/\/ Returns [undefined, undefined, ....] with 10 items<\/code><\/pre>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f <code>.map<\/code>\u00a0\u043c\u0435\u0442\u043e\u0434, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u0440\u043e\u0439\u0442\u0438\u0441\u044c \u043f\u043e \u043c\u0430\u0441\u0441\u0438\u0432\u0443 \u0438 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0435 \u0441\u043b\u043e\u0432\u043e.<\/p>\n<pre><code class=\"javascript\">[...Array(10)].map(() => getRandomWord()) \/\/ Returns [\"hand\", \"close\", \"ship\", \"possibly\", \"metal\", \"myself\", \"everybody\", \"serious\", \"adult\", \"favorite\"]<\/code><\/pre>\n<p>\u0412 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u043e \u043c\u0430\u0441\u0441\u0438\u0432 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0445 \u0441\u043b\u043e\u0432, \u043d\u043e \u0447\u0442\u043e\u0431\u044b \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0435\u0433\u043e \u0441\u0442\u0440\u043e\u043a\u043e\u0439, \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0442\u044c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u043f\u0440\u043e\u0431\u0435\u043b\u043e\u043c. \u042d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434\u043e\u043c <code>.join('')<\/code>.  <\/p>\n<pre><code class=\"javascript\">[...Array(10)].map(() => getRandomWord()).join('')<\/code><\/pre>\n<p>\u0422\u0430\u043a\u0436\u0435 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0447\u0438\u0442\u0430\u0431\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u043d\u0430\u0448\u0435\u0439 \u0441\u0442\u0440\u043e\u043a\u0435, \u0430 \u0438\u043c\u0435\u043d\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043f\u0435\u0440\u0432\u043e\u0435 \u0441\u043b\u043e\u0432\u043e \u0441 \u0437\u0430\u0433\u043b\u0430\u0432\u043d\u043e\u0439 \u0431\u0443\u043a\u0432\u044b. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043e\u0431\u043d\u043e\u0432\u0438\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e <code>getRandomWord<\/code>\u00a0.<\/p>\n<pre><code class=\"javascript\">function getRandomWord(firstLetterToUppercase = false) {     const word = words[randomNumber(0, words.length - 1)];     return firstLetterToUppercase ? word.charAt(0).toUpperCase() + word.slice(1) : word; }<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e <code>generateWords<\/code> . \u0422\u0435\u043f\u0435\u0440\u044c \u0432\u00a0<code>getRandomWord(i === 0)<\/code> \u0431\u0443\u0434\u0435\u043c \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u0441 0, \u0447\u0442\u043e\u0431\u044b \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043f\u0435\u0440\u0432\u043e\u0435 \u0441\u043b\u043e\u0432\u043e (\u0447\u0435\u0439 \u0438\u043d\u0434\u0435\u043a\u0441 \u043a\u0430\u043a \u0440\u0430\u0437 \u0440\u0430\u0432\u0435\u043d 0) \u0437\u0430\u0433\u043b\u0430\u0432\u043d\u044b\u043c.<\/p>\n<pre><code class=\"javascript\">function generateWords(length = 10) {     return [...Array(length)].map((_, i) => getRandomWord(i === 0)).join(' ').trim() + '.'; }<\/code><\/pre>\n<hr\/>\n<h3>4. \u0417\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u0435<\/h3>\n<p>\u041c\u044b \u043d\u0430\u043f\u0438\u0441\u0430\u043b\u0438 \u0432\u0441\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u0442\u0430\u043a \u0447\u0442\u043e \u043c\u043e\u0436\u0435\u043c \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043d\u0430 \u0432\u0435\u0441\u044c \u043a\u043e\u0434.<\/p>\n<pre><code class=\"javascript\">const word = [     \"Got\",     \"ability\",     \"shop\",     \"recall\",     \"fruit\",     \"easy\",     \"dirty\",     \"giant\",     \"shaking\",     \"ground\",     \"weather\",     \"lesson\",     \"almost\",     \"square\",     \"forward\",     \"bend\",     \"cold\",     \"broken\",     \"distant\",     \"adjective.\" ] function getRandomWord(firstLetterToUppercase = false) {     const word = words[randomNumber(0, words.length - 1)];     return firstLetterToUppercase ? word.charAt(0).toUpperCase() + word.slice(1) : word; } function generateWords(length = 10) {     return [...Array(length)].map((_, i) => getRandomWord(i === 0)).join(' ').trim() + '.'; } function randomNumber(min, max) {     return Math.round(Math.random() * (max - min) + min); }<\/code><\/pre>\n<p>\u041f\u0440\u043e\u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u043d\u0430 <a href=\"https:\/\/runkit.com\/devbyrayray\/how-to-generate-a-string-with-random-words\" rel=\"noopener noreferrer nofollow\">Runkit<\/a>.<\/p>\n<p>\u0421\u043f\u0430\u0441\u0438\u0431\u043e \u0437\u0430 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435.<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"v-portal\" style=\"display:none;\"><\/div>\n<\/div>\n<p> <!----> <!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/652531\/\"> https:\/\/habr.com\/ru\/post\/652531\/<\/a><br \/><\/br><\/br><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-329874","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/329874","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=329874"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/329874\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=329874"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=329874"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=329874"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}