8000 javascript-exercises/repeatString at master · matt-stanley/javascript-exercises · GitHub
[go: up one dir, main page]

Skip to content
< 4929 script type="application/json" data-target="react-app.embeddedData">{"payload":{"allShortcutsEnabled":false,"path":"repeatString","repo":{"id":296510294,"defaultBranch":"master","name":"javascript-exercises","ownerLogin":"matt-stanley","currentUserCanPush":false,"isFork":true,"isEmpty":false,"createdAt":"2020-09-18T04:08:17.000Z","ownerAvatar":"https://avatars.githubusercontent.com/u/70910731?v=4","public":true,"private":false,"isOrgOwned":false},"currentUser":null,"refInfo":{"name":"master","listCacheKey":"v0:1631569639.983773","canEdit":false,"refType":"branch","currentOid":"21c90f05e5aaa71b059f4417d367ca2ed0d06d3f"},"tree":{"items":[{"name":"README.md","path":"repeatString/README.md","contentType":"file"},{"name":"repeatString.js","path":"repeatString/repeatString.js","contentType":"file"},{"name":"repeatString.spec.js","path":"repeatString/repeatString.spec.js","contentType":"file"}],"templateDirectorySuggestionUrl":null,"readme":{"displayName":"README.md","richText":"\u003carticle class=\"markdown-body entry-content container-lg\" itemprop=\"text\"\u003e\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch1 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003eExercise 02 - repeatString\u003c/h1\u003e\u003ca id=\"user-content-exercise-02---repeatstring\" class=\"anchor\" aria-label=\"Permalink: Exercise 02 - repeatString\" href=\"#exercise-02---repeatstring\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003eWrite a function that simply repeats the string a given number of times:\u003c/p\u003e\n\u003cdiv class=\"highlight highlight-source-js notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"repeatString('hey', 3) // returns 'heyheyhey'\"\u003e\u003cpre\u003e\u003cspan class=\"pl-en\"\u003erepeatString\u003c/span\u003e\u003cspan class=\"pl-kos\"\u003e(\u003c/span\u003e\u003cspan class=\"pl-s\"\u003e'hey'\u003c/span\u003e\u003cspan class=\"pl-kos\"\u003e,\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e3\u003c/span\u003e\u003cspan class=\"pl-kos\"\u003e)\u003c/span\u003e \u003cspan class=\"pl-c\"\u003e// returns 'heyheyhey'\u003c/span\u003e\u003c/pre\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003eYou will notice in this exercise that there are multiple tests (see in file \u003ccode\u003erepeatString.spec.js\u003c/code\u003e). Only the first test is currently enabled. So after making sure that this first one passes, enable the others one by one by deleting the \u003ccode\u003ex\u003c/code\u003e in front of the \u003ccode\u003eit()\u003c/code\u003e function.\u003c/p\u003e\n\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch2 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003eHints\u003c/h2\u003e\u003ca id=\"user-content-hints\" class=\"anchor\" aria-label=\"Permalink: Hints\" href=\"#hints\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cul dir=\"auto\"\u003e\n\u003cli\u003e\n\u003cp dir=\"auto\"\u003eYou're going to want to use a loop for this one.\u003c/p\u003e\n\u003c/li\u003e\n\u003cli\u003e\n\u003cp dir=\"auto\"\u003eCreate a variable to hold the string you're going to return, create a loop that repeats the given number of times and add the given string to the result on each loop.\u003c/p\u003e\n\u003c/li\u003e\n\u003cli\u003e\n\u003cp dir=\"auto\"\u003eIf running \u003ccode\u003ejasmine repeatString.spec.js\u003c/code\u003e raises \u003ccode\u003eTemporarily disabled with xit\u003c/code\u003e errors, make sure you have enabled the rest of the tests (see above).\u003c/p\u003e\n\u003c/li\u003e\n\u003c/ul\u003e\n\u003c/article\u003e","errorMessage":null,"headerInfo":{"toc":[{"level":1,"text":"Exercise 02 - repeatString","anchor":"exercise-02---repeatstring","htmlText":"Exercise 02 - repeatString"},{"level":2,"text":"Hints","anchor":"hints","htmlText":"Hints"}],"siteNavLoginPath":"/login?return_to=https%3A%2F%2Fgithub.com%2Fmatt-stanley%2Fjavascript-exercises%2Ftree%2Fmaster%2FrepeatString"}},"totalCount":3,"showBranchInfobar":true},"fileTree":{"":{"items":[{"name":"caesar","path":"caesar","contentType":"directory"},{"name":"calculator","path":"calculator","contentType":"directory"},{"name":"fibonacci","path":"fibonacci","contentType":"directory"},{"name":"findTheOldest","path":"findTheOldest","contentType":"directory"},{"name":"generator-exercise","path":"generator-exercise","contentType":"directory"},{"name":"getTheTitles","path":"getTheTitles","contentType":"directory"},{"name":"helloWorld","path":"helloWorld","contentType":"directory"},{"name":"leapYears","path":"leapYears","contentType":"directory"},{"name":"palindromes","path":"palindromes","contentType":"directory"},{"name":"pig_latin","path":"pig_latin","contentType":"directory"},{"name":"removeFromArray","path":"removeFromArray","contentType":"directory"},{"name":"repeatString","path":"repeatString","contentType":"directory"},{"name":"reverseString","path":"reverseString","contentType":"directory"},{"name":"snakeCase","path":"snakeCase","contentType":"directory"},{"name":"sumAll","path":"sumAll","contentType":"directory"},{"name":"tempConversion","path":"tempConversion","contentType":"directory"},{"name":".gitignore","path":".gitignore","contentType":"file"},{"name":"README.md","path":"README.md","contentType":"file"}],"totalCount":18}},"fileTreeProcessingTime":1.721928,"foldersToFetch":[],"treeExpanded":true,"symbolsExpanded":false,"csrf_tokens":{"/matt-stanley/javascript-exercises/branches":{"post":"iEmIZE6YfBoKA_PR5NCdD_LwuWkMendZOHl3G0El5Ufw3SqE0oFqRfaNMqNKovLrVY0sDPGVPPqxEnz9pWvHgg"},"/matt-stanley/javascript-exercises/branches/fetch_and_merge/master":{"post":"KwnFQ0M0-weOx2HePVtzn_e9lDfkSdZUIzypPPhRUbYGadUExAxQ3PIyjeAHtOceBnPw6h_XKLDoj58h3m6gYA"},"/matt-stanley/javascript-exercises/branches/fetch_and_merge/master?discard_changes=true":{"post":"N15L5_P1lEXOFiext9yJT7iJth8wwoD5rmTPvu1Ss1IaPlugdM0_nrLjy4-NMx3OSUfSwstcfh1l1_mjy21ChA"}}},"title":"javascript-exercises/repeatString at master · matt-stanley/javascript-exercises","appPayload":{"helpUrl":"https://docs.github.com","findFileWorkerPath":"/assets-cdn/worker/find-file-worker-7d7eb7c71814.js","findInFileWorkerPath":"/assets-cdn/worker/find-in-file-worker-1ae9fa256942.js","githubDevUrl":null,"enabled_features":{"code_nav_ui_events":false,"react_blob_overlay":false,"accessible_code_button":true,"github_models_repo_integration":false}}}
0