diff --git a/1-js/3-writing-js/4-testing/3-pow-test-wrong/solution.md b/1-js/3-writing-js/4-testing/3-pow-test-wrong/solution.md index 12679a07..97b66bbc 100644 --- a/1-js/3-writing-js/4-testing/3-pow-test-wrong/solution.md +++ b/1-js/3-writing-js/4-testing/3-pow-test-wrong/solution.md @@ -19,7 +19,7 @@ describe("Возводит x в степень n", function() { }); it("5 в степени 3 равно 125", function() { - assert.equal(pow(5, 3), 25); + assert.equal(pow(5, 3), 125); }); }); ``` diff --git a/12-extra/10-cookie/cookie.js b/12-extra/10-cookie/cookie.js new file mode 100644 index 00000000..896993d6 --- /dev/null +++ b/12-extra/10-cookie/cookie.js @@ -0,0 +1,45 @@ +// возвращает cookie с именем name, если есть, если нет, то undefined +function getCookie(name) { + var matches = document.cookie.match(new RegExp( + "(?:^|; )" + name.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g, '\\$1') + "=([^;]*)" + )); + return matches ? decodeURIComponent(matches[1]) : undefined; +} + +// устанавливает cookie c именем name и значением value +// options - объект с свойствами cookie (expires, path, domain, secure) +function setCookie(name, value, options) { + options = options || {}; + + var expires = options.expires; + + if (typeof expires == "number" && expires) { + var d = new Date(); + d.setTime(d.getTime() + expires * 1000); + expires = options.expires = d; + } + if (expires && expires.toUTCString) { + options.expires = expires.toUTCString(); + } + + value = encodeURIComponent(value); + + var updatedCookie = name + "=" + value; + + for (var propName in options) { + updatedCookie += "; " + propName; + var propValue = options[propName]; + if (propValue !== true) { + updatedCookie += "=" + propValue; + } + } + + document.cookie = updatedCookie; +} + +// удаляет cookie с именем name +function deleteCookie(name) { + setCookie(name, "", { + expires: -1 + }) +} \ No newline at end of file diff --git a/8-css-for-js/8-white-space/article.md b/8-css-for-js/8-white-space/article.md index 7291e9da..a3f14533 100644 --- a/8-css-for-js/8-white-space/article.md +++ b/8-css-for-js/8-white-space/article.md @@ -38,34 +38,41 @@ ```js //+ no-beautify if (hours > 18) { - // Пойти поиграть в теннис + // Пойти поиграть в теннис } ``` -