├── .devcontainer └── devcontainer.json ├── .github └── workflows │ └── learnpack-audit.yml ├── .gitignore ├── .gitpod.Dockerfile ├── .gitpod.yml ├── .vscode └── settings.json ├── CHANGELOG.md ├── README.es.md ├── README.md ├── exercises ├── 00-Welcome │ ├── README.es.md │ └── README.md ├── 001-isOldEnoughToDrink │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 002-isOldEnoughToDrive │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 003-isOldEnoughToVote │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 004-isOldEnoughToDrinkAndDrive │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 005-checkAge │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 006-getFullName │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 007-getLengthOfWord │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 008-getLengthOfTwoWords │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 009-getLengthOfThreeWords │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 010-isSameLength │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 011-isGreaterThanTen │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solutions.hide.js │ └── test.js ├── 012-isLessThanThirty │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 013-equalsTen │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 014-isLessThan │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 015-isGreaterThan │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 016-isEqualTo │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 017-isEven │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 018-isOdd │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 019-areBothOdd │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 020-isEitherEven │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 021-isOddLength │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 022-isEvenLength │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 023-computeAverageLengthOfWords │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 024-isEvenAndGreaterThanTen │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 025-average │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 026-computeAreaOfATriangle │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 027-cube │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 028-square │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 029-getProperty │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 030-addProperty │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 031-removeProperty │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 032-addFullNameProperty │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 033-addObjectProperty │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 034-isPersonOldEnoughToDrive │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 035-isPersonOldEnoughToVote │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 036-isPersonOldEnoughToDrink │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 037-addArrayProperty │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 038-computeAreaOfARectangle │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 039-computePerimeterOfARectangle │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 040-computePerimeterOfATriangle │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 041-computeTripledAreaOfARectangle │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 042-computePerimeterOfACircle │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 043-computeAreaOfACircle │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 044-computePower │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 045-computeSquareRoot │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 046-doubleSquareRootOf │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 047-isEitherEvenOrAreBoth7 │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 048-isEitherEvenAndLessThan9 │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 049-computeAverageOfNumbers │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 050-getNthElement │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 051-getFirstElement │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 052-getLastElement │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 053-addToFront │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 054-addToBack │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 055-joinArrays │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 056-getElementsAfter │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 057-getElementsUpTo │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 058-removeFromFront │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 059-removeFromBack │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 060-removeFromFrontOfNew │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 061-removeFromBackOfNew │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 062-countCharacter │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 063-getAllLetters │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 064-getAllWords │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 065-or │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 066-extend │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 067-removeNumbersLargerThan │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 068-removeNumbersLessThan │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 069-removeStringValuesLongerThan │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 070-removeEvenValues │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 071-countNumberOfKeys │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 072-removeOddValues │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 073-removeArrayValues │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 074-removeNumberValues │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 075-removeStringValues │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 076-convertDoubleSpaceToSingle │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 077-areValidCredentials │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 078-getIndexOf │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 079-findMinLengthOfThreeWords │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 080-findMaxLengthOfThreeWords │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 081-repeatString │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 082-getLongestOfThreeWords │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 083-findShortestOfThreeWords │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 084-joinThreeArrays │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 085-addToFrontOfNew │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 086-addToBackOfNew │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 087-getAllElementsButNth │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 088-keep │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 089-removeElement │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 090-filterOddLengthWords │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 091-filterEvenLengthWords │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 092-getFirstElementOfProperty │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 093-getNthElementOfProperty │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 094-getLastElementOfProperty │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 095-getElementsThatEqual10AtProperty │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 096-getElementsLessThanOneHundredAtProperty │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 097-getElementsGreaterThanTenAtProperty │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 098-getOddLengthWordsAtProperty │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 099-getAverageOfElementsAtProperty │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 100-getEvenLengthWordsAtProperty │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 101-getOddElementsAtProperty │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 102-getEvenElementsAtProperty │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 103-getSquaredElementsAtProperty │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 104-getSmallestElementAtProperty │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 105-getLargestElementAtProperty │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 106-getAllButLastElementOfProperty │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 107-getElementOfArrayProperty │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 108-getProductOfAllElementsAtProperty │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 109-Select │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 110-getSumOfAllElementsAtProperty │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 111-countAllCharacters │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 112-getLengthOfLongestElement │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 113-squareElements │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 114-filterOddElements │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 115-computeProductOfAllElements │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 116-filterEvenElements │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 117-getLengthOfShortestElement │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 118-getLongestElement │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 119-findSmallestElement │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 120-findShortestElement │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 121-getLargestElement │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 122-computeSumOfAllElements │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 123-joinArraysOfArrays │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 124-findShortestWordAmongMixedElements │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 125-findSmallestnumberAmongMixedElements │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 126-getLongestWordOfMixedElements │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 127-getLargestNumberAmongMixedElements │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 128-averageIntegers │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 129-calculateBillTotal │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 130-multiplyBetween │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 131-computeSumBetween │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 132-computeSummationToN │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 133-convertScoreToGrade │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 134-convertScoreToGradeWithPlus │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 135-computeFactorialOfN │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 136-sumDigits │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 137-computeCompoundInterest │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 138-modulo │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 139-multiply │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 140-isOddWithoutModulo │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 141-isEvenWithoutModulo │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 142.1-ArrayToObject │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 142.2-ArrayToObject │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 142.3-ArrayToObject │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 143.1-ObjectToArray │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 143.2-ObjectToArray │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 143.3-ObjectToArray │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 144-getStringLength │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 145-GreetCustomers │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 146-flipPairs │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 147-flipEveryNChars │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 148-detectOutlierValue │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 149-findPairForSum │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 150-isRotated │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 151-search │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 152-isogram │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 153-phoneNumber │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 154-longestPalindrome │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 155.1-FashionInventory-A │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 155.2-FashionInventory-B │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── 155.3-FashionInventory-C │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js └── 155.4-FashionInventory-D │ ├── README.es.md │ ├── README.md │ ├── app.js │ ├── solution.hide.js │ └── test.js ├── learn.json └── preview.jpeg /.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore everything 2 | /* 3 | 4 | !.gitignore 5 | !.gitpod.yml 6 | !.gitpod.Dockerfile 7 | !bc.json 8 | !README.md 9 | !README.es.md 10 | !.vscode 11 | 12 | !/exercises 13 | !/exercises/* 14 | 15 | !/.breathecode 16 | /.breathecode/** 17 | !/.breathecode/resets 18 | !/.breathecode/resets/** -------------------------------------------------------------------------------- /.gitpod.Dockerfile: -------------------------------------------------------------------------------- 1 | FROM gitpod/workspace-full 2 | 3 | USER gitpod 4 | 5 | RUN npm i jest@29.7.0 jest-environment-jsdom@29.7.0 -g 6 | RUN npm i @learnpack/learnpack@2.1.50 -g && learnpack plugins:install @learnpack/node@1.1.13 7 | -------------------------------------------------------------------------------- /.gitpod.yml: -------------------------------------------------------------------------------- 1 | image: 2 | file: .gitpod.Dockerfile 3 | 4 | ports: 5 | - port: 3000 6 | onOpen: ignore 7 | 8 | vscode: 9 | extensions: 10 | - learn-pack.learnpack-vscode 11 | 12 | 13 | github: 14 | prebuilds: 15 | # enable for the master/default branch (defaults to true) 16 | master: true 17 | # enable for pull requests coming from this repo (defaults to true) 18 | pullRequests: false 19 | # add a "Review in Gitpod" button as a comment to pull requests (defaults to true) 20 | addComment: false -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "files.autoSave": "afterDelay", 3 | "files.autoSaveDelay": 700, 4 | "editor.minimap.enabled": false, 5 | "workbench.editorAssociations": { 6 | "*.md": "vscode.markdown.preview.editor" 7 | } 8 | } -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | 1. Added exercises from 1 to 20 by Mike Berrio 4 | 2. On July 20, 2020: Added exercises from 20 to 30 to Mike Berrio (i know that it is conflicting with Kristina). 5 | 6 | # Planning 7 | 8 | 1. Added exercises from 21 to 40 to Kristina Frants 9 | 3. Added exercises from 41 to 60 to Kevin Castillo 10 | 4. Added exercises from 61 to 80 to Eduard Chiticari 11 | 5. Added exercises from 81 to 100 to Jorge Montes 12 | 13 | # Sep 24 14 | 15 | I tested the first exercises until 09, we need to test them all. -------------------------------------------------------------------------------- /exercises/001-isOldEnoughToDrink/README.es.md: -------------------------------------------------------------------------------- 1 | # `001` isOldEnoughToDrink 2 | 3 | ## 📝 Instrucciones: 4 | 5 | 1. Escribe una función llamada `isOldEnoughToDrink`. Dado un número, en este caso una edad, `isOldEnoughToDrink` retorna si la persona de esa edad tiene la edad necesaria para beber legalmente en los Estados Unidos. 6 | 7 | ## 📎 Ejemplo: 8 | 9 | ```javascript 10 | let output = isOldEnoughToDrink(22); 11 | console.log(output); // --> true 12 | ``` 13 | 14 | ## 💡 Pista: 15 | 16 | + La edad legal para poder beber en los Estados Unidos es de 21 años. 17 | -------------------------------------------------------------------------------- /exercises/001-isOldEnoughToDrink/README.md: -------------------------------------------------------------------------------- 1 | # `001` isOldEnoughToDrink 2 | 3 | ## 📝 Instructions: 4 | 5 | 1. Write a function called `isOldEnoughToDrink`. Given a number, in this case an age, `isOldEnoughToDrink` returns whether a person of this given age is old enough to legally drink in the United States. 6 | 7 | ## 📎 Example: 8 | 9 | ```javascript 10 | let output = isOldEnoughToDrink(22); 11 | console.log(output); // --> true 12 | ``` 13 | 14 | ## 💡 Hint: 15 | 16 | + The legal drinking age in the United States is 21. 17 | -------------------------------------------------------------------------------- /exercises/001-isOldEnoughToDrink/app.js: -------------------------------------------------------------------------------- 1 | function isOldEnoughToDrink(age) { 2 | // your code here 3 | 4 | } 5 | -------------------------------------------------------------------------------- /exercises/001-isOldEnoughToDrink/solution.hide.js: -------------------------------------------------------------------------------- 1 | function isOldEnoughToDrink(age) { 2 | // your code here 3 | if(age >= 21) return true; 4 | else return false; 5 | } 6 | -------------------------------------------------------------------------------- /exercises/002-isOldEnoughToDrive/README.es.md: -------------------------------------------------------------------------------- 1 | # `002` isOldEnoughToDrive 2 | 3 | ## 📝 Instrucciones: 4 | 5 | Escribe una función llamada `isOldEnoughToDrive` que dado un número, en este caso una edad, `isOldEnoughToDrive` retorna si la persona de esa edad tiene la edad necesaria para conducir legalmente en los Estados Unidos. 6 | 7 | ## 📎 Ejemplo: 8 | 9 | ```javascript 10 | let output = isOldEnoughToDrive(22); 11 | console.log(output); // --> true 12 | ``` 13 | 14 | ## 💡 Pista: 15 | 16 | + La edad legal para poder conducir en los Estados Unidos es de 16 años. 17 | -------------------------------------------------------------------------------- /exercises/002-isOldEnoughToDrive/README.md: -------------------------------------------------------------------------------- 1 | # `002` isOldEnoughToDrive 2 | 3 | ## 📝 Instructions: 4 | 5 | 1. Write a function called `isOldEnoughToDrive`. Given a number, in this case an age, `isOldEnoughToDrive` returns whether a person of this given age is old enough to legally drive in the United States. 6 | 7 | ## 📎 Example: 8 | 9 | ```javascript 10 | let output = isOldEnoughToDrive(22); 11 | console.log(output); // --> true 12 | ``` 13 | 14 | ## 💡 Hint: 15 | 16 | + The legal driving age in the United States is 16. 17 | -------------------------------------------------------------------------------- /exercises/002-isOldEnoughToDrive/app.js: -------------------------------------------------------------------------------- 1 | function isOldEnoughToDrive(age) { 2 | // your code here 3 | 4 | } 5 | -------------------------------------------------------------------------------- /exercises/002-isOldEnoughToDrive/solution.hide.js: -------------------------------------------------------------------------------- 1 | function isOldEnoughToDrive(age) { 2 | // your code here 3 | if(age >= 16) return true; 4 | else return false; 5 | } 6 | -------------------------------------------------------------------------------- /exercises/003-isOldEnoughToVote/README.es.md: -------------------------------------------------------------------------------- 1 | # `003` isOldEnoughToVote 2 | 3 | ## 📝 Instrucciones: 4 | 5 | 1. Escribe una función llamada `isOldEnoughToVote`. Dado un número, en este caso una edad, `isOldEnoughToVote` retorna si la persona de esa edad tiene la edad necesaria para votar legalmente en los Estados Unidos. 6 | 7 | ## 📎 Ejemplo: 8 | 9 | ```Javascript 10 | let output = isOldEnoughToVote(22); 11 | console.log(output); // --> true 12 | ``` 13 | 14 | ## 💡 Pista: 15 | 16 | + La edad legal para poder votar en los Estados Unidos es de 18 años. 17 | -------------------------------------------------------------------------------- /exercises/003-isOldEnoughToVote/README.md: -------------------------------------------------------------------------------- 1 | # `003` isOldEnoughToVote 2 | 3 | ## 📝 Insructions: 4 | 5 | 1. Write a function called `isOldEnoughToVote`. Given a number, in this case an age, `isOldEnoughToVote` returns whether a person of this given age is old enough to legally vote in the United States. 6 | 7 | ## 📎 Example: 8 | 9 | ```Javascript 10 | let output = isOldEnoughToVote(22); 11 | console.log(output); // --> true 12 | ``` 13 | 14 | ## 💡 Hint: 15 | 16 | + The legal voting age in the United States is 18. 17 | -------------------------------------------------------------------------------- /exercises/003-isOldEnoughToVote/app.js: -------------------------------------------------------------------------------- 1 | function isOldEnoughToVote(age) { 2 | // your code here 3 | 4 | } 5 | -------------------------------------------------------------------------------- /exercises/003-isOldEnoughToVote/solution.hide.js: -------------------------------------------------------------------------------- 1 | function isOldEnoughToVote(age) { 2 | // your code here 3 | if(age >= 18) return true; 4 | else return false; 5 | } -------------------------------------------------------------------------------- /exercises/004-isOldEnoughToDrinkAndDrive/app.js: -------------------------------------------------------------------------------- 1 | function isOldEnoughToDrinkAndDrive(age) { 2 | // your code here 3 | 4 | } 5 | -------------------------------------------------------------------------------- /exercises/004-isOldEnoughToDrinkAndDrive/solution.hide.js: -------------------------------------------------------------------------------- 1 | function isOldEnoughToDrinkAndDrive(age) { 2 | // your code here 3 | return false; 4 | } -------------------------------------------------------------------------------- /exercises/005-checkAge/app.js: -------------------------------------------------------------------------------- 1 | function checkAge(name, age) { 2 | // your code here 3 | 4 | } 5 | -------------------------------------------------------------------------------- /exercises/005-checkAge/solution.hide.js: -------------------------------------------------------------------------------- 1 | function checkAge(name, age) { 2 | // your code here 3 | if(age < 21) return `Go home, ${name}!` 4 | else return `Welcome, ${name}!` 5 | } -------------------------------------------------------------------------------- /exercises/006-getFullName/README.es.md: -------------------------------------------------------------------------------- 1 | # `006` getFullName 2 | 3 | ## 📝 Instrucciones: 4 | 5 | 1. Escribe una función llamada `getFullName`. Dado un nombre y un apellido, `getFullName` retorna un string con el nombre y apellido separados por un espacio. 6 | 7 | ## 📎 Ejemplo: 8 | 9 | ```Javascript 10 | let output = getFullName('Joe', 'Smith'); 11 | console.log(output); // --> 'Joe Smith' 12 | ``` 13 | -------------------------------------------------------------------------------- /exercises/006-getFullName/README.md: -------------------------------------------------------------------------------- 1 | # `006` getFullName 2 | 3 | ## 📝 Instructions: 4 | 5 | 1. Write a function called `getFullName`. Given a first and a last name, `getFullName` returns a single string with the given first and last names separated by a single space. 6 | 7 | ## 📎 Example: 8 | 9 | ```Javascript 10 | let output = getFullName('Joe', 'Smith'); 11 | console.log(output); // --> 'Joe Smith' 12 | ``` 13 | -------------------------------------------------------------------------------- /exercises/006-getFullName/app.js: -------------------------------------------------------------------------------- 1 | function getFullName(firstName, lastName) { 2 | // your code here 3 | 4 | } 5 | -------------------------------------------------------------------------------- /exercises/006-getFullName/solution.hide.js: -------------------------------------------------------------------------------- 1 | function getFullName(firstName, lastName) { 2 | // your code here 3 | return firstName + " " + lastName 4 | } -------------------------------------------------------------------------------- /exercises/007-getLengthOfWord/README.es.md: -------------------------------------------------------------------------------- 1 | # `007` getLengthOfWord 2 | 3 | ## 📝 Instrucciones: 4 | 5 | 1. Escribe una función llamada `getLengthOfWord`. Dada un palabra, `getLengthOfWord` debe retornar la cantidad de letras que tiene esa palabra. 6 | 7 | ## 📎 Ejemplo: 8 | 9 | ```Javascript 10 | let output = getLengthOfWord('some'); 11 | console.log(output); // --> 4 12 | ``` 13 | -------------------------------------------------------------------------------- /exercises/007-getLengthOfWord/README.md: -------------------------------------------------------------------------------- 1 | # `007` getLengthOfWord 2 | 3 | ## 📝 Instructions: 4 | 5 | 1. Write a function called `getLengthOfWord`. Given a word, `getLengthOfWord` returns the length of the given word. 6 | 7 | ## 📎 Example: 8 | 9 | ```Javascript 10 | let output = getLengthOfWord('some'); 11 | console.log(output); // --> 4 12 | ``` 13 | -------------------------------------------------------------------------------- /exercises/007-getLengthOfWord/app.js: -------------------------------------------------------------------------------- 1 | function getLengthOfWord(word) { 2 | // your code here 3 | 4 | } 5 | -------------------------------------------------------------------------------- /exercises/007-getLengthOfWord/solution.hide.js: -------------------------------------------------------------------------------- 1 | function getLengthOfWord(word) { 2 | // your code here 3 | return word.length; 4 | } -------------------------------------------------------------------------------- /exercises/008-getLengthOfTwoWords/README.es.md: -------------------------------------------------------------------------------- 1 | # `008` getLengthOfTwoWords 2 | 3 | ## 📝 Instrucciones: 4 | 5 | 1. Escribe una función llamada `getLengthOfTwoWords`. Dadas dos palabras, `getLengthOfTwoWords` retorna la **suma** de sus letras. 6 | 7 | ## 📎 Ejemplo: 8 | 9 | ```Javascript 10 | let output = getLengthOfTwoWords('some', 'words'); 11 | console.log(output); // --> 9 12 | ``` 13 | -------------------------------------------------------------------------------- /exercises/008-getLengthOfTwoWords/README.md: -------------------------------------------------------------------------------- 1 | # `008` getLengthOfTwoWords 2 | 3 | ## 📝 Instructions: 4 | 5 | 1. Write a function called `getLengthOfTwoWords`. Given 2 words, `getLengthOfTwoWords` returns the **sum** of their lengths. 6 | 7 | ## 📎 Example: 8 | 9 | ```Javascript 10 | let output = getLengthOfTwoWords('some', 'words'); 11 | console.log(output); // --> 9 12 | ``` 13 | -------------------------------------------------------------------------------- /exercises/008-getLengthOfTwoWords/app.js: -------------------------------------------------------------------------------- 1 | function getLengthOfTwoWords(word1, word2) { 2 | // your code here 3 | 4 | } 5 | -------------------------------------------------------------------------------- /exercises/008-getLengthOfTwoWords/solution.hide.js: -------------------------------------------------------------------------------- 1 | function getLengthOfTwoWords(word1, word2) { 2 | // your code here 3 | return word1.length + word2.length 4 | } -------------------------------------------------------------------------------- /exercises/009-getLengthOfThreeWords/README.es.md: -------------------------------------------------------------------------------- 1 | # `009` getLengthOfThreeWords 2 | 3 | ## 📝 Instrucciones: 4 | 5 | 1. Escribe una función llamada `getLengthOfThreeWords`. Dadas 3 palabras, `getLengthOfThreeWords` retorna la suma de sus letras. 6 | 7 | ## 📎 Ejemplo: 8 | 9 | ```Javascript 10 | let output = getLengthOfThreeWords('some', 'other', 'words'); 11 | console.log(output); // --> 14 12 | ``` 13 | 14 | ## 💡 Pista: 15 | 16 | + Recuerda usar la función `length` para saber la longitud de una cadena/string. 17 | -------------------------------------------------------------------------------- /exercises/009-getLengthOfThreeWords/README.md: -------------------------------------------------------------------------------- 1 | # `009` getLengthOfThreeWords 2 | 3 | ## 📝 Instructions: 4 | 5 | 1. Write a function called `getLengthOfThreeWords`. Given 3 words, `getLengthOfThreeWords` returns the sum of their lengths. 6 | 7 | ## 📎 Example: 8 | 9 | ```Javascript 10 | let output = getLengthOfThreeWords('some', 'other', 'words'); 11 | console.log(output); // --> 14 12 | ``` 13 | 14 | ## 💡 Hint: 15 | 16 | + Remember to use the function `length` on strings to know its length. 17 | -------------------------------------------------------------------------------- /exercises/009-getLengthOfThreeWords/app.js: -------------------------------------------------------------------------------- 1 | function getLengthOfThreeWords(word1, word2, word3) { 2 | // your code here 3 | 4 | } 5 | 6 | let output = getLengthOfThreeWords('some', 'other', 'words'); 7 | console.log(output); // --> 14 8 | -------------------------------------------------------------------------------- /exercises/009-getLengthOfThreeWords/solution.hide.js: -------------------------------------------------------------------------------- 1 | function getLengthOfThreeWords(word1, word2, word3) { 2 | // your code here 3 | let length1 = word1.length; 4 | let length2 = word2.length; 5 | let length3 = word3.length; 6 | let sumOfLengths = length1 + length2 + length3; 7 | return sumOfLengths; 8 | } 9 | 10 | let output = getLengthOfThreeWords('some', 'other', 'words'); 11 | console.log(output); // --> 14 12 | -------------------------------------------------------------------------------- /exercises/010-isSameLength/README.es.md: -------------------------------------------------------------------------------- 1 | # `010` isSameLength 2 | 3 | ## 📝 Instructiones: 4 | 5 | 1. Escribe una función llamada `isSameLength`. Dadas dos palabras, `isSameLength` retorna `true` si ambas palabras tienen la misma cantidad de letras. De lo contrario retorna `false`. 6 | 7 | ## 📎 Ejemplo: 8 | 9 | ```Javascript 10 | let output = isSameLength('words', 'super'); 11 | console.log(output); // --> true 12 | ``` 13 | -------------------------------------------------------------------------------- /exercises/010-isSameLength/README.md: -------------------------------------------------------------------------------- 1 | # `010` isSameLength 2 | 3 | ## 📝 Instructions: 4 | 5 | 1. Write a function called `isSameLength`. Given two words, `isSameLength` returns `true` if the given words have the same length. Otherwise it returns `false`. 6 | 7 | ## 📎 Example: 8 | 9 | ```Javascript 10 | let output = isSameLength('words', 'super'); 11 | console.log(output); // --> true 12 | ``` 13 | -------------------------------------------------------------------------------- /exercises/010-isSameLength/app.js: -------------------------------------------------------------------------------- 1 | // Write your function here -------------------------------------------------------------------------------- /exercises/010-isSameLength/solution.hide.js: -------------------------------------------------------------------------------- 1 | // Write your function here 2 | function isSameLength(word1, word2) { 3 | return word1.length === word2.length 4 | } 5 | -------------------------------------------------------------------------------- /exercises/011-isGreaterThanTen/README.es.md: -------------------------------------------------------------------------------- 1 | # `011` isGreaterThanTen 2 | 3 | ## 📝 Instrucciones: 4 | 5 | 1. Escribe una función llamada `isGreaterThanTen`. Dado un número, `isGreaterThanTen` retorna `true` si este es mayor a 10, si no retorna `false`. 6 | 7 | ## 📎 Ejemplo: 8 | 9 | ```Javascript 10 | let output = isGreaterThanTen(11); 11 | console.log(output); // --> true 12 | ``` 13 | -------------------------------------------------------------------------------- /exercises/011-isGreaterThanTen/README.md: -------------------------------------------------------------------------------- 1 | # `011` isGreaterThanTen 2 | 3 | ## 📝 Instructions: 4 | 5 | 1. Write a function called `isGreaterThanTen`. Given a number, `isGreaterThanTen` returns `true` if it is greater than 10, otherwise it returns `false`. 6 | 7 | ## 📎 Example: 8 | 9 | ```Javascript 10 | let output = isGreaterThanTen(11); 11 | console.log(output); // --> true 12 | ``` 13 | -------------------------------------------------------------------------------- /exercises/011-isGreaterThanTen/app.js: -------------------------------------------------------------------------------- 1 | function isGreaterThanTen(num) { 2 | // your code here 3 | 4 | } 5 | -------------------------------------------------------------------------------- /exercises/011-isGreaterThanTen/solutions.hide.js: -------------------------------------------------------------------------------- 1 | function isGreaterThanTen(num) { 2 | // your code here 3 | if(num > 10) return true 4 | else return false 5 | } -------------------------------------------------------------------------------- /exercises/012-isLessThanThirty/README.es.md: -------------------------------------------------------------------------------- 1 | # `012` isLessThan30 2 | 3 | ## 📝 Instrucciones: 4 | 5 | 1. Escribe una función llamada `isLessThan30`. Dado un número, `isLessThan30` retorna `true` si ese número es menor de 30. De lo contrario retorna `false`. 6 | 7 | ## 📎 Ejemplo: 8 | 9 | ```Javascript 10 | let output = isLessThan30(9); 11 | console.log(output); // --> true 12 | ``` 13 | -------------------------------------------------------------------------------- /exercises/012-isLessThanThirty/README.md: -------------------------------------------------------------------------------- 1 | # `012` isLessThan30 2 | 3 | ## 📝 Instructions: 4 | 5 | 1. Write a function called `isLessThan30`. Given a number, `isLessThan30` returns `true` if the given number is less than 30. Otherwise it returns `false`. 6 | 7 | ## 📎 Example: 8 | 9 | ```Javascript 10 | let output = isLessThan30(9); 11 | console.log(output); // --> true 12 | ``` 13 | -------------------------------------------------------------------------------- /exercises/012-isLessThanThirty/app.js: -------------------------------------------------------------------------------- 1 | function isLessThan30(num) { 2 | // your code here 3 | 4 | } 5 | -------------------------------------------------------------------------------- /exercises/012-isLessThanThirty/solution.hide.js: -------------------------------------------------------------------------------- 1 | function isLessThan30(num) { 2 | // your code here 3 | if(num < 30) return true 4 | else return false 5 | } -------------------------------------------------------------------------------- /exercises/013-equalsTen/README.es.md: -------------------------------------------------------------------------------- 1 | # `013` equalsTen 2 | 3 | ## 📝 Instrucciones: 4 | 5 | 1. Escribe una función llamada `equalsTen`. Dado un número, `equalsTen` retorna `true` si ese número es igual a 10. De lo contrario retorna `false`. 6 | 7 | ## 📎 Ejemplo: 8 | 9 | ```Javascript 10 | let output = equalsTen(9); 11 | console.log(output); // --> false 12 | ``` 13 | 14 | ## 💡 Pista: 15 | 16 | + Recuerda usar tres signos iguales (===) para comparar valores exactos. [Haz clic aquí para mayor info](https://bytearcher.com/articles/equality-comparison-operator-javascript) 17 | -------------------------------------------------------------------------------- /exercises/013-equalsTen/README.md: -------------------------------------------------------------------------------- 1 | # `013` equalsTen 2 | 3 | ## 📝 Instructions: 4 | 5 | 1. Write a function called `equalsTen`. Given a number, `equalsTen` returns `true` if the given number is 10. Otherwise it returns `false`. 6 | 7 | ## 📎 Example: 8 | 9 | ```Javascript 10 | let output = equalsTen(9); 11 | console.log(output); // --> false 12 | ``` 13 | 14 | ## 💡 Hint: 15 | 16 | + Remember to use three equal signs (===) to compare exact values. [Read more about it here](https://bytearcher.com/articles/equality-comparison-operator-javascript) 17 | -------------------------------------------------------------------------------- /exercises/013-equalsTen/app.js: -------------------------------------------------------------------------------- 1 | function equalsTen(num) { 2 | // your code here 3 | 4 | } 5 | -------------------------------------------------------------------------------- /exercises/013-equalsTen/solution.hide.js: -------------------------------------------------------------------------------- 1 | function equalsTen(num) { 2 | // your code here 3 | if(num === 10) return true; 4 | else return false; 5 | } 6 | -------------------------------------------------------------------------------- /exercises/014-isLessThan/README.es.md: -------------------------------------------------------------------------------- 1 | # `014` isLessThan 2 | 3 | ## 📝 Instrucciones: 4 | 5 | 1. Escribe una función llamada `isLessThan`. Dados 2 números, `isLessThan` retorna `true` si `num2` es menor que `num1`. De lo contrario retorna `false`. 6 | 7 | ## 📎 Ejemplo: 8 | 9 | ```Javascript 10 | let output = isLessThan(9, 4); 11 | console.log(output); // --> true 12 | ``` 13 | -------------------------------------------------------------------------------- /exercises/014-isLessThan/README.md: -------------------------------------------------------------------------------- 1 | # `014` isLessThan 2 | 3 | ## 📝 Instructions: 4 | 5 | 1. Write a function called `isLessThan`. Given 2 numbers, `isLessThan` returns `true` if `num2` is less than `num1`. Otherwise it returns `false`. 6 | 7 | ## 📎 Example: 8 | 9 | ```Javascript 10 | let output = isLessThan(9, 4); 11 | console.log(output); // --> true 12 | ``` 13 | -------------------------------------------------------------------------------- /exercises/014-isLessThan/app.js: -------------------------------------------------------------------------------- 1 | function isLessThan(num1, num2) { 2 | // your code here 3 | } 4 | -------------------------------------------------------------------------------- /exercises/014-isLessThan/solution.hide.js: -------------------------------------------------------------------------------- 1 | function isLessThan(num1, num2) { 2 | // your code here 3 | return (num2 < num1); 4 | } 5 | -------------------------------------------------------------------------------- /exercises/015-isGreaterThan/README.es.md: -------------------------------------------------------------------------------- 1 | # `015` isGreaterThan 2 | 3 | ## 📝 Instrucciones: 4 | 5 | 1. Escribe una función llamada `isGreaterThan`. Dados 2 números, `isGreaterThan` retorna `true` si `num2` es mayor que `num1`. De lo contrario retorna `false`. 6 | 7 | ## 📎 Ejemplo: 8 | 9 | ```Javascript 10 | let output = isGreaterThan(11, 10); 11 | console.log(output); // --> false 12 | ``` 13 | -------------------------------------------------------------------------------- /exercises/015-isGreaterThan/README.md: -------------------------------------------------------------------------------- 1 | # `015` isGreaterThan 2 | 3 | ## 📝 Instructions: 4 | 5 | 1. Write a function called `isGreaterThan`. Given 2 numbers, `isGreaterThan` returns `true` if `num2` is greater than `num1`. Otherwise it returns `false`. 6 | 7 | ## 📎 Example: 8 | 9 | ```Javascript 10 | let output = isGreaterThan(11, 10); 11 | console.log(output); // --> false 12 | ``` 13 | -------------------------------------------------------------------------------- /exercises/015-isGreaterThan/app.js: -------------------------------------------------------------------------------- 1 | function isGreaterThan(num1, num2) { 2 | // your code here 3 | 4 | } 5 | -------------------------------------------------------------------------------- /exercises/015-isGreaterThan/solution.hide.js: -------------------------------------------------------------------------------- 1 | function isGreaterThan(num1, num2) { 2 | // your code here 3 | return num2 > num1; 4 | } -------------------------------------------------------------------------------- /exercises/016-isEqualTo/README.es.md: -------------------------------------------------------------------------------- 1 | # `016` isEqualTo 2 | 3 | ## 📝 Instrucciones: 4 | 5 | 1. Escribe una función llamada `isEqualTo`. Dados 2 números, `isEqualTo` retorna `true` si `num2` es igual a `num1`. De lo contrario retorna `false`. 6 | 7 | ## 📎 Ejemplo: 8 | 9 | ```Javascript 10 | let output = isEqualTo(11, 10); 11 | console.log(output); // --> false 12 | ``` 13 | -------------------------------------------------------------------------------- /exercises/016-isEqualTo/README.md: -------------------------------------------------------------------------------- 1 | # `016` isEqualTo 2 | 3 | ## 📝 Instructions: 4 | 5 | 1. Write a function called `isEqualTo`. Given 2 numbers, `isEqualTo` returns `true` if `num2` is equal to `num1`. Otherwise it returns `false`. 6 | 7 | ## 📎 Example: 8 | 9 | ```Javascript 10 | let output = isEqualTo(11, 10); 11 | console.log(output); // --> false 12 | ``` 13 | -------------------------------------------------------------------------------- /exercises/016-isEqualTo/app.js: -------------------------------------------------------------------------------- 1 | // Write your function here -------------------------------------------------------------------------------- /exercises/016-isEqualTo/solution.hide.js: -------------------------------------------------------------------------------- 1 | // Write your function here 2 | function isEqualTo(a, b) { 3 | return a === b 4 | } 5 | -------------------------------------------------------------------------------- /exercises/017-isEven/README.es.md: -------------------------------------------------------------------------------- 1 | # `017` isEven 2 | 3 | ## 📝 Instrucciones: 4 | 5 | 1. Escribe una función llamada `isEven`. Dado un número, `isEven` retorna `true` si el número es par. De lo contrario retorna `false`. 6 | 7 | ## 📎 Ejemplo: 8 | 9 | ```Javascript 10 | let output = isEven(11); 11 | console.log(output); // --> false 12 | ``` 13 | -------------------------------------------------------------------------------- /exercises/017-isEven/README.md: -------------------------------------------------------------------------------- 1 | # `017` isEven 2 | 3 | ## 📝 Instructions: 4 | 5 | 1. Write a function called `isEven`. Given a number, `isEven` returns `true` if it is even. Otherwise it returns `false`. 6 | 7 | ## 📎 Example: 8 | 9 | ```Javascript 10 | let output = isEven(11); 11 | console.log(output); // --> false 12 | ``` 13 | -------------------------------------------------------------------------------- /exercises/017-isEven/app.js: -------------------------------------------------------------------------------- 1 | // Write your function here -------------------------------------------------------------------------------- /exercises/017-isEven/solution.hide.js: -------------------------------------------------------------------------------- 1 | // Write your function here 2 | function isEven(num) { 3 | return num % 2 === 0 4 | } 5 | -------------------------------------------------------------------------------- /exercises/018-isOdd/README.es.md: -------------------------------------------------------------------------------- 1 | # `018` isOdd 2 | 3 | ## 📝 Instrucciones: 4 | 5 | 1. Escribe una función llamada `isOdd`. Dado un número, `isOdd` retorna `true` si el número es impar. De lo contrario retorna `false`. 6 | 7 | ## 📎 Ejemplo: 8 | 9 | ```Javascript 10 | let output = isOdd(9); 11 | console.log(output); // --> true 12 | ``` 13 | -------------------------------------------------------------------------------- /exercises/018-isOdd/README.md: -------------------------------------------------------------------------------- 1 | # `018` isOdd 2 | 3 | ## 📝 Instructions: 4 | 5 | 1. Write a function called `isOdd`. Given a number, `isOdd` returns `true` if the given number is odd. Otherwise it returns `false`. 6 | 7 | ## 📎 Example: 8 | 9 | ```Javascript 10 | let output = isOdd(9); 11 | console.log(output); // --> true 12 | ``` 13 | -------------------------------------------------------------------------------- /exercises/018-isOdd/app.js: -------------------------------------------------------------------------------- 1 | // Write your function here -------------------------------------------------------------------------------- /exercises/018-isOdd/solution.hide.js: -------------------------------------------------------------------------------- 1 | // Write your function here 2 | function isOdd(num) { 3 | return num % 2 > 0; 4 | } 5 | -------------------------------------------------------------------------------- /exercises/019-areBothOdd/README.es.md: -------------------------------------------------------------------------------- 1 | # `019` areBothOdd 2 | 3 | ## 📝 Instrucciones: 4 | 5 | 1. Escribe una función llamada `areBothOdd`, que dados 2 números, `areBothOdd` retorna `true` si ambos números son impares, de lo contrario retorna `false`. 6 | 7 | ## 📎 Ejemplo: 8 | 9 | ```js 10 | let output = areBothOdd(1, 3); 11 | console.log(output); // --> true 12 | ``` 13 | -------------------------------------------------------------------------------- /exercises/019-areBothOdd/README.md: -------------------------------------------------------------------------------- 1 | # `019` areBothOdd 2 | 3 | ## 📝 Instructions: 4 | 5 | 1. Write a function called `areBothOdd`. Given 2 numbers, `areBothOdd` returns `true` if both numbers are odd, otherwise it should return `false`. 6 | 7 | ## 📎 Example: 8 | 9 | ```Javascript 10 | let output = areBothOdd(1, 3); 11 | console.log(output); // --> true 12 | ``` 13 | -------------------------------------------------------------------------------- /exercises/019-areBothOdd/app.js: -------------------------------------------------------------------------------- 1 | // Write your function here 2 | -------------------------------------------------------------------------------- /exercises/019-areBothOdd/solution.hide.js: -------------------------------------------------------------------------------- 1 | // Write your function here 2 | function areBothOdd(a,b) { 3 | return (a % 2 > 0) && (b % 2 > 0) 4 | } 5 | -------------------------------------------------------------------------------- /exercises/020-isEitherEven/README.es.md: -------------------------------------------------------------------------------- 1 | # `020` isEitherEven 2 | 3 | ## 📝 Instrucciones: 4 | 5 | 1. Escribe una función llamada `isEitherEven`, que dados 2 números, `isEitherEven` retorna `true` si uno de los números es par, de lo contrario retorna `false`. 6 | 7 | ## 📎 Ejemplo: 8 | 9 | ```Javascript 10 | let output = isEitherEven(1, 4); 11 | console.log(output); // --> true 12 | ``` 13 | -------------------------------------------------------------------------------- /exercises/020-isEitherEven/README.md: -------------------------------------------------------------------------------- 1 | # `020` isEitherEven 2 | 3 | ## 📝 Instructions: 4 | 5 | 1. Write a function called `isEitherEven`. Given 2 numbers, `isEitherEven` returns `true` if one of the numbers is even, otherwise it should return `false`. 6 | 7 | ## 📎 Example: 8 | 9 | ```Javascript 10 | let output = isEitherEven(1, 4); 11 | console.log(output); // --> true 12 | ``` 13 | -------------------------------------------------------------------------------- /exercises/020-isEitherEven/app.js: -------------------------------------------------------------------------------- 1 | // Write your function here -------------------------------------------------------------------------------- /exercises/020-isEitherEven/solution.hide.js: -------------------------------------------------------------------------------- 1 | // Write your function here 2 | function isEitherEven(n1, n2) { 3 | if (n1 % 2 == 0 || n2 % 2 == 0) return true; 4 | else return false; 5 | } 6 | -------------------------------------------------------------------------------- /exercises/021-isOddLength/README.es.md: -------------------------------------------------------------------------------- 1 | # `021` isOddLength 2 | 3 | ## 📝 Instrucciones: 4 | 5 | 1. Escribe una función llamada `isOddLength`. Dada una palabra, `isOddLength` retorna `true` si la cantidad de letras que tiene la palabra es impar, de lo contrario retorna `false`. 6 | 7 | ## 📎 Ejemplo: 8 | 9 | ```Javascript 10 | let output = isOddLength('special'); 11 | console.log(output); // true 12 | ``` 13 | -------------------------------------------------------------------------------- /exercises/021-isOddLength/README.md: -------------------------------------------------------------------------------- 1 | # `021` isOddLength 2 | 3 | ## 📝 Instructions: 4 | 5 | 1. Write a function called `isOddLength`. Given a word, `isOddLength` returns `true` if the length of the given word is odd, otherwise it returns `false`. 6 | 7 | ## 📎 Example: 8 | 9 | ```Javascript 10 | let output = isOddLength('special'); 11 | console.log(output); // --> true 12 | ``` 13 | -------------------------------------------------------------------------------- /exercises/021-isOddLength/app.js: -------------------------------------------------------------------------------- 1 | // Write your function here 2 | -------------------------------------------------------------------------------- /exercises/021-isOddLength/solution.hide.js: -------------------------------------------------------------------------------- 1 | // Write your function here 2 | function isOddLength(word) { 3 | return (word.length % 2 > 0); 4 | } 5 | -------------------------------------------------------------------------------- /exercises/022-isEvenLength/README.es.md: -------------------------------------------------------------------------------- 1 | # `022` isEvenLength 2 | 3 | ## 📝 Instrucciones: 4 | 5 | 1. Escribe una función llamada `isEvenLength`. Dada una palabra, `isEvenLength` retorna `true` si la cantidad de letras que tiene la palabra es par, de lo contrario retorna `false`. 6 | 7 | ## 📎 Ejemplo: 8 | 9 | ```Javascript 10 | let output = isEvenLength('wow'); 11 | console.log(output); // --> false 12 | ``` 13 | -------------------------------------------------------------------------------- /exercises/022-isEvenLength/README.md: -------------------------------------------------------------------------------- 1 | # `022` isEvenLength 2 | 3 | ## 📝 Instructions: 4 | 5 | 1. Write a function called `isEvenLength`. Given a word, `isEvenLength` returns `true` if the length of the given word is even, otherwise it returns `false`. 6 | 7 | ## 📎 Example: 8 | 9 | ```Javascript 10 | let output = isEvenLength('wow'); 11 | console.log(output); // --> false 12 | ``` 13 | -------------------------------------------------------------------------------- /exercises/022-isEvenLength/app.js: -------------------------------------------------------------------------------- 1 | // Write your function here -------------------------------------------------------------------------------- /exercises/022-isEvenLength/solution.hide.js: -------------------------------------------------------------------------------- 1 | // Write your function here 2 | function isEvenLength(word) { 3 | return word.length % 2 == 0 4 | } 5 | -------------------------------------------------------------------------------- /exercises/023-computeAverageLengthOfWords/README.es.md: -------------------------------------------------------------------------------- 1 | # `023` computeAverageLengthOfWords 2 | 3 | ## 📝 Instrucciones: 4 | 5 | 1. Escribe una función llamada `computeAverageLengthOfWords`. Dadas dos palabras, `computeAverageLengthOfWords` retorna el promedio de la cantidad de letras de ambas. 6 | 7 | ## 📎 Ejemplo: 8 | 9 | ```Javascript 10 | let output = computeAverageLengthOfWords('code', 'programs'); 11 | console.log(output); // --> 6 12 | ``` 13 | -------------------------------------------------------------------------------- /exercises/023-computeAverageLengthOfWords/README.md: -------------------------------------------------------------------------------- 1 | # `023` computeAverageLengthOfWords 2 | 3 | ## 📝 Instructions: 4 | 5 | 1. Write a function called `computeAverageLengthOfWords`. Given two words, `computeAverageLengthOfWords` returns the average of their lengths. 6 | 7 | ## 📎 Example: 8 | 9 | ```Javascript 10 | let output = computeAverageLengthOfWords('code', 'programs'); 11 | console.log(output); // --> 6 12 | ``` 13 | -------------------------------------------------------------------------------- /exercises/023-computeAverageLengthOfWords/app.js: -------------------------------------------------------------------------------- 1 | // Write your function here -------------------------------------------------------------------------------- /exercises/023-computeAverageLengthOfWords/solution.hide.js: -------------------------------------------------------------------------------- 1 | // Write your function here 2 | function computeAverageLengthOfWords(word1, word2) { 3 | return (word1.length + word2.length) / 2 4 | } 5 | -------------------------------------------------------------------------------- /exercises/024-isEvenAndGreaterThanTen/README.es.md: -------------------------------------------------------------------------------- 1 | # `024` isEvenAndGreaterThanTen 2 | 3 | ## 📝 Instrucciones: 4 | 5 | 1. Escribe una función llamada `isEvenAndGreaterThanTen`. Dado un número, `isEvenAndGreaterThanTen` retorna `true` si el número es par y mayor que 10, de lo contrario retorna `false`. 6 | 7 | ## 📎 Ejemplo: 8 | 9 | ```Javascript 10 | let output = isEvenAndGreaterThanTen(13); 11 | console.log(output); // --> false 12 | ``` 13 | -------------------------------------------------------------------------------- /exercises/024-isEvenAndGreaterThanTen/README.md: -------------------------------------------------------------------------------- 1 | # `024` isEvenAndGreaterThanTen 2 | 3 | ## 📝 Instructions: 4 | 5 | 1. Write a function called `isEvenAndGreaterThanTen`. Given a number, `isEvenAndGreaterThanTen` returns `true` if the number is both even and greater than 10, otherwise it returns `false`. 6 | 7 | ## 📎 Example: 8 | 9 | ```Javascript 10 | let output = isEvenAndGreaterThanTen(13); 11 | console.log(output); // --> false 12 | ``` 13 | -------------------------------------------------------------------------------- /exercises/024-isEvenAndGreaterThanTen/app.js: -------------------------------------------------------------------------------- 1 | // Write your function here -------------------------------------------------------------------------------- /exercises/024-isEvenAndGreaterThanTen/solution.hide.js: -------------------------------------------------------------------------------- 1 | // Write your function here 2 | function isEvenAndGreaterThanTen(num) { 3 | return num > 10 && num % 2 === 0 4 | } 5 | -------------------------------------------------------------------------------- /exercises/025-average/README.es.md: -------------------------------------------------------------------------------- 1 | # `025` Average 2 | 3 | ## 📝 Instrucciones: 4 | 5 | 1. Escribe una función llamada `average`. Dados 2 números, `average` retorna su promedio. 6 | 7 | ## 📎 Ejemplo: 8 | 9 | ```Javascript 10 | let output = average(4, 6); 11 | console.log(output); // --> 5 12 | ``` 13 | -------------------------------------------------------------------------------- /exercises/025-average/README.md: -------------------------------------------------------------------------------- 1 | # `025` Average 2 | 3 | ## 📝 Instructions: 4 | 5 | 1. Write a function called `average`. Given two numbers, `average` returns their average. 6 | 7 | ## 📎 Example: 8 | 9 | ```Javascript 10 | let output = average(4, 6); 11 | console.log(output); // --> 5 12 | ``` 13 | -------------------------------------------------------------------------------- /exercises/025-average/app.js: -------------------------------------------------------------------------------- 1 | // Write your function here -------------------------------------------------------------------------------- /exercises/025-average/solution.hide.js: -------------------------------------------------------------------------------- 1 | // Write your function here 2 | function average(a, b) { 3 | return (a + b) / 2 4 | } 5 | -------------------------------------------------------------------------------- /exercises/026-computeAreaOfATriangle/README.es.md: -------------------------------------------------------------------------------- 1 | # `026` computeAreaOfATriangle 2 | 3 | ## 📝 Instrucciones: 4 | 5 | 1. Escribe una función llamada `computeAreaOfATriangle`. Dada la base y altura de un triangulo, `computeAreaOfATriangle` retorna el área de un triángulo. 6 | 7 | ## 📎 Ejemplo: 8 | 9 | ```Javascript 10 | let output = computeAreaOfATriangle(4, 6); 11 | console.log(output); // --> 12 12 | ``` 13 | -------------------------------------------------------------------------------- /exercises/026-computeAreaOfATriangle/README.md: -------------------------------------------------------------------------------- 1 | # `026` computeAreaOfATriangle 2 | 3 | ## 📝 Instructions: 4 | 5 | 1. Write a function called `computeAreaOfATriangle`. Given the base and height of a triangle `computeAreaOfATriangle` returns its area. 6 | 7 | ## 📎 Example: 8 | 9 | ```Javascript 10 | let output = computeAreaOfATriangle(4, 6); 11 | console.log(output); // --> 12 12 | ``` 13 | -------------------------------------------------------------------------------- /exercises/026-computeAreaOfATriangle/app.js: -------------------------------------------------------------------------------- 1 | // Write your function here 2 | -------------------------------------------------------------------------------- /exercises/026-computeAreaOfATriangle/solution.hide.js: -------------------------------------------------------------------------------- 1 | // Write your function here 2 | function computeAreaOfATriangle(a, b) { 3 | return (a * b) / 2 4 | } 5 | -------------------------------------------------------------------------------- /exercises/027-cube/README.es.md: -------------------------------------------------------------------------------- 1 | # `027` cube 2 | 3 | ## 📝 Instrucciones: 4 | 5 | 1. Escribe una función llamada `cube`. Dado un número, `cube` retorna el cubo de ese número. 6 | 7 | ## 📎 Ejemplo: 8 | 9 | ```Javascript 10 | let output = cube(3); 11 | console.log(output); // --> 27 12 | ``` 13 | -------------------------------------------------------------------------------- /exercises/027-cube/README.md: -------------------------------------------------------------------------------- 1 | # `027` cube 2 | 3 | ## 📝 Instructions: 4 | 5 | 1. Write a function called `cube`. Given a number, `cube` returns the cube of that number. 6 | 7 | ## 📎 Example: 8 | 9 | ```Javascript 10 | let output = cube(3); 11 | console.log(output); // --> 27 12 | ``` 13 | -------------------------------------------------------------------------------- /exercises/027-cube/app.js: -------------------------------------------------------------------------------- 1 | // Write your function here -------------------------------------------------------------------------------- /exercises/027-cube/solution.hide.js: -------------------------------------------------------------------------------- 1 | // Write your function here 2 | function cube(n) { 3 | return n * n * n 4 | } 5 | -------------------------------------------------------------------------------- /exercises/028-square/README.es.md: -------------------------------------------------------------------------------- 1 | # `028` square 2 | 3 | ## 📝 Instrucciones: 4 | 5 | 1. Escribe una función llamada `square`. Dado un número, `square` retorna el cuadrado de dicho número. 6 | 7 | ## 📎 Ejemplo: 8 | 9 | ```Javascript 10 | let output = square(5); 11 | console.log(output); // --> 25 12 | ``` 13 | -------------------------------------------------------------------------------- /exercises/028-square/README.md: -------------------------------------------------------------------------------- 1 | # `028` square 2 | 3 | ## 📝 Instructions: 4 | 5 | 1. Write a function called `square`. Given a number, `square` should return the square of the given number. 6 | 7 | ## 📎 Example: 8 | 9 | ```Javascript 10 | let output = square(5); 11 | console.log(output); // --> 25 12 | ``` 13 | -------------------------------------------------------------------------------- /exercises/028-square/app.js: -------------------------------------------------------------------------------- 1 | // Write your function here 2 | -------------------------------------------------------------------------------- /exercises/028-square/solution.hide.js: -------------------------------------------------------------------------------- 1 | // Write your function here 2 | function square(n) { 3 | return n * n 4 | } 5 | -------------------------------------------------------------------------------- /exercises/029-getProperty/README.es.md: -------------------------------------------------------------------------------- 1 | # `029` getProperty 2 | 3 | ## 📝 Instrucciones: 4 | 5 | 1. Escribe una función llamada `getProperty`. Dado un objeto y una key, `getProperty` retorna el valor de la propiedad con esa key. 6 | 7 | ## 📎 Ejemplo: 8 | 9 | ```Javascript 10 | let car = { 11 | model: 'Toyota' 12 | }; 13 | let output = getProperty(car, 'model'); 14 | console.log(output); // --> 'Toyota' 15 | ``` 16 | -------------------------------------------------------------------------------- /exercises/029-getProperty/README.md: -------------------------------------------------------------------------------- 1 | # `029` getProperty 2 | 3 | ## 📝 Instructions: 4 | 5 | 1. Write a function called `getProperty`. Given an object and a key, `getProperty` returns the value of the property at the given key. 6 | 7 | ## 📎 Example: 8 | 9 | ```Javascript 10 | let car = { 11 | model: 'Toyota' 12 | }; 13 | let output = getProperty(car, 'model'); 14 | console.log(output); // --> 'Toyota' 15 | ``` 16 | -------------------------------------------------------------------------------- /exercises/029-getProperty/app.js: -------------------------------------------------------------------------------- 1 | function getProperty(obj, key) { 2 | // your code here 3 | 4 | } 5 | -------------------------------------------------------------------------------- /exercises/029-getProperty/solution.hide.js: -------------------------------------------------------------------------------- 1 | function getProperty(obj, key) { 2 | // your code here 3 | return obj[key]; 4 | } -------------------------------------------------------------------------------- /exercises/030-addProperty/README.es.md: -------------------------------------------------------------------------------- 1 | # `030` addProperty 2 | 3 | ## 📝 Instrucciones: 4 | 5 | 1. Escribe una función llamada `addProperty`. Dado un objeto y una key, `addProperty` agrega la key al objeto con el valor `true`. 6 | 7 | Luego, la función tiene que devolver el objeto. 8 | 9 | ## 📎 Ejemplo: 10 | 11 | ```Javascript 12 | let myObj = {}; 13 | addProperty(myObj, 'myProperty'); 14 | console.log(myObj.myProperty); // --> true 15 | ``` 16 | -------------------------------------------------------------------------------- /exercises/030-addProperty/README.md: -------------------------------------------------------------------------------- 1 | # `030` addProperty 2 | 3 | ## 📝 Instructions 4 | 5 | 1. Write a function called `addProperty`. Given an object, and a key, `addProperty` sets a new property on the given object with a value of `true`. 6 | 7 | Then, the function must return the object. 8 | 9 | ## 📎 Example: 10 | 11 | ```Javascript 12 | let myObj = {}; 13 | addProperty(myObj, 'myProperty'); 14 | console.log(myObj.myProperty); // --> true 15 | ``` 16 | -------------------------------------------------------------------------------- /exercises/030-addProperty/app.js: -------------------------------------------------------------------------------- 1 | function addProperty(obj, key) { 2 | // your code here 3 | 4 | } 5 | -------------------------------------------------------------------------------- /exercises/030-addProperty/solution.hide.js: -------------------------------------------------------------------------------- 1 | function addProperty(obj, key) { 2 | // your code here 3 | obj[key] = true 4 | return obj 5 | } -------------------------------------------------------------------------------- /exercises/031-removeProperty/README.es.md: -------------------------------------------------------------------------------- 1 | # `031` removeProperty 2 | 3 | ## 📝 Instrucciones: 4 | 5 | 1. Escribe una función llamada `removeProperty`. Dado un objeto y una key, `removeProperty` elimina la key de ese objeto dado. 6 | 7 | ## 📎 Ejemplo: 8 | 9 | ```Javascript 10 | let obj = { 11 | name: 'Sam', 12 | age: 20 13 | } 14 | removeProperty(obj, 'name'); 15 | console.log(obj.name); // --> undefined 16 | ``` 17 | 18 | ## 💡 Pista: 19 | + https://developer.mozilla.org/es/docs/Web/JavaScript/Reference/Operators/delete 20 | -------------------------------------------------------------------------------- /exercises/031-removeProperty/README.md: -------------------------------------------------------------------------------- 1 | # `031` removeProperty 2 | 3 | ## 📝 Instructions: 4 | 5 | 1. Write a function called `removeProperty`. Given an object and a key, `removeProperty` removes the given key from the given object. 6 | 7 | ## 📎 Example: 8 | 9 | ```Javascript 10 | let obj = { 11 | name: 'Sam', 12 | age: 20 13 | } 14 | removeProperty(obj, 'name'); 15 | console.log(obj.name); // --> undefined 16 | ``` 17 | 18 | ## 💡 Hint: 19 | - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/delete 20 | -------------------------------------------------------------------------------- /exercises/031-removeProperty/app.js: -------------------------------------------------------------------------------- 1 | function removeProperty(obj, key) { 2 | // your code here 3 | 4 | } 5 | -------------------------------------------------------------------------------- /exercises/031-removeProperty/solution.hide.js: -------------------------------------------------------------------------------- 1 | function removeProperty(obj, key) { 2 | // your code here 3 | delete obj[key] 4 | } -------------------------------------------------------------------------------- /exercises/032-addFullNameProperty/app.js: -------------------------------------------------------------------------------- 1 | function addFullNameProperty(obj) { 2 | // Add your code after this line 3 | 4 | } -------------------------------------------------------------------------------- /exercises/032-addFullNameProperty/solution.hide.js: -------------------------------------------------------------------------------- 1 | function addFullNameProperty(obj) { 2 | // Add your code after this line 3 | obj.fullName = obj.firstName + " " + obj.lastName; 4 | return obj 5 | } 6 | 7 | console.log(addFullNameProperty({ firstName: "Elias", lastName: "Toroa" })) -------------------------------------------------------------------------------- /exercises/033-addObjectProperty/app.js: -------------------------------------------------------------------------------- 1 | function addObjectProperty(obj1, key, obj2) { 2 | // Add your code after this line 3 | 4 | } -------------------------------------------------------------------------------- /exercises/033-addObjectProperty/solution.hide.js: -------------------------------------------------------------------------------- 1 | function addObjectProperty(obj1, key, obj2) { 2 | // Add your code after this line 3 | obj1[key] = obj2 4 | return obj1 5 | } 6 | -------------------------------------------------------------------------------- /exercises/034-isPersonOldEnoughToDrive/app.js: -------------------------------------------------------------------------------- 1 | function isPersonOldEnoughToDrive(person) { 2 | // Add your code after this line 3 | 4 | } -------------------------------------------------------------------------------- /exercises/034-isPersonOldEnoughToDrive/solution.hide.js: -------------------------------------------------------------------------------- 1 | function isPersonOldEnoughToDrive(person) { 2 | // Add your code after this line 3 | if (person.age >= 16) return true; 4 | return false; 5 | } 6 | -------------------------------------------------------------------------------- /exercises/035-isPersonOldEnoughToVote/app.js: -------------------------------------------------------------------------------- 1 | function isPersonOldEnoughToVote(person) { 2 | // Add your code after this line 3 | 4 | } -------------------------------------------------------------------------------- /exercises/035-isPersonOldEnoughToVote/solution.hide.js: -------------------------------------------------------------------------------- 1 | function isPersonOldEnoughToDrive(person) { 2 | // Add your code after this line 3 | if (person.age >= 18) return true; 4 | return false; 5 | } 6 | -------------------------------------------------------------------------------- /exercises/036-isPersonOldEnoughToDrink/app.js: -------------------------------------------------------------------------------- 1 | function isPersonOldEnoughToDrink(person) { 2 | // Add your code after this line 3 | 4 | } -------------------------------------------------------------------------------- /exercises/036-isPersonOldEnoughToDrink/solution.hide.js: -------------------------------------------------------------------------------- 1 | function isPersonOldEnoughToDrink(person) { 2 | // Add your code after this line 3 | if (person.age >= 21) return true; 4 | return false; 5 | } 6 | -------------------------------------------------------------------------------- /exercises/037-addArrayProperty/app.js: -------------------------------------------------------------------------------- 1 | function addArrayProperty(obj, key, arr) { 2 | // Add your code after this line 3 | 4 | } -------------------------------------------------------------------------------- /exercises/037-addArrayProperty/solution.hide.js: -------------------------------------------------------------------------------- 1 | function addArrayProperty(obj, key, arr) { 2 | // Add your code after this line 3 | obj[key] = arr 4 | return obj 5 | } 6 | -------------------------------------------------------------------------------- /exercises/038-computeAreaOfARectangle/README.es.md: -------------------------------------------------------------------------------- 1 | # `038` computeAreaOfARectangle 2 | 3 | ## 📝 Instrucciones: 4 | 5 | 1. Escribe una función llamada `computeAreaOfARectangle`. Dado el largo y ancho de un rectágulo, `computeAreaOfARectangle` devuelve su área. 6 | 7 | ## 📎 Ejemplo: 8 | 9 | ```Javascript 10 | let output = computeAreaOfARectangle(4, 8); 11 | console.log(output); // --> 32 12 | ``` 13 | -------------------------------------------------------------------------------- /exercises/038-computeAreaOfARectangle/README.md: -------------------------------------------------------------------------------- 1 | # `038` computeAreaOfARectangle 2 | 3 | ## 📝 Instructions: 4 | 5 | 1. Write a function called `computeAreaOfARectangle`. Given the length and width of a rectangle, `computeAreaOfARectangle` returns its area. 6 | 7 | ## 📎 Example: 8 | 9 | ```Javascript 10 | let output = computeAreaOfARectangle(4, 8); 11 | console.log(output); // --> 32 12 | ``` 13 | -------------------------------------------------------------------------------- /exercises/038-computeAreaOfARectangle/app.js: -------------------------------------------------------------------------------- 1 | function computeAreaOfARectangle(length, width) { 2 | // your code here 3 | 4 | } 5 | 6 | let output = computeAreaOfARectangle(10, 18); 7 | console.log(output) // --> 180 8 | -------------------------------------------------------------------------------- /exercises/038-computeAreaOfARectangle/solution.hide.js: -------------------------------------------------------------------------------- 1 | function computeAreaOfARectangle(length, width) { 2 | // your code here 3 | let area = length * width; 4 | return area; 5 | } 6 | 7 | let output = computeAreaOfARectangle(10, 18); 8 | console.log(output) // --> 180 9 | -------------------------------------------------------------------------------- /exercises/039-computePerimeterOfARectangle/README.es.md: -------------------------------------------------------------------------------- 1 | # `039` computePerimeterOfARectangle 2 | 3 | ## 📝 Instrucciones: 4 | 5 | 1. Escribe una función llamada `computePerimeterOfARectangle`. Dado el largo y ancho de un rectángulo, `computePerimeterOfARectangle` retorna su perímetro. 6 | 7 | ## 📎 Ejemplo: 8 | 9 | ```Javascript 10 | let output = computePerimeterOfARectangle(5, 2); 11 | console.log(output); // --> 14 12 | ``` 13 | -------------------------------------------------------------------------------- /exercises/039-computePerimeterOfARectangle/README.md: -------------------------------------------------------------------------------- 1 | # `039` computePerimeterOfARectangle 2 | 3 | ## 📝 Instructions: 4 | 5 | 1. Write a function called `computePerimeterOfARectangle`. Given the length and width of a rectangle, `computePerimeterOfARectangle` returns its perimeter. 6 | 7 | ## 📎 Example: 8 | 9 | ```Javascript 10 | let output = computePerimeterOfARectangle(5, 2); 11 | console.log(output); // --> 14 12 | ``` 13 | -------------------------------------------------------------------------------- /exercises/039-computePerimeterOfARectangle/app.js: -------------------------------------------------------------------------------- 1 | function computePerimeterOfARectangle(length, width) { 2 | // your code here 3 | } 4 | 5 | let output = computePerimeterOfARectangle(5, 2); 6 | console.log(output); // --> 14 7 | -------------------------------------------------------------------------------- /exercises/039-computePerimeterOfARectangle/solution.hide.js: -------------------------------------------------------------------------------- 1 | function computePerimeterOfARectangle(length, width) { 2 | // your code here 3 | let perimeter = 2 * (length + width); 4 | return perimeter; 5 | } 6 | 7 | let output = computePerimeterOfARectangle(5, 2); 8 | console.log(output); // --> 14 9 | -------------------------------------------------------------------------------- /exercises/040-computePerimeterOfATriangle/README.es.md: -------------------------------------------------------------------------------- 1 | # `040` computePerimeterOfATriangle 2 | 3 | ## 📝 Instrucciones: 4 | 5 | 1. Escribe una función llamada `computePerimeterOfATriangle`. Dados 3 lados de un triángulo, `computePerimeterOfATriangle` retorna su perímetro. 6 | 7 | ## 📎 Ejemplo: 8 | 9 | ```Javascript 10 | let output = computePerimeterOfATriangle(6, 4, 10); 11 | console.log(output); // --> 20 12 | ``` 13 | -------------------------------------------------------------------------------- /exercises/040-computePerimeterOfATriangle/README.md: -------------------------------------------------------------------------------- 1 | # `040` computePerimeterOfATriangle 2 | 3 | ## 📝 Instructions: 4 | 5 | 1. Write a function called `computePerimeterOfATriangle`. Given 3 sides describing a triangle, `computePerimeterOfATriangle` returns its perimeter. 6 | 7 | ## 📎 Example: 8 | 9 | ```Javascript 10 | let output = computePerimeterOfATriangle(6, 4, 10); 11 | console.log(output); // --> 20 12 | ``` 13 | -------------------------------------------------------------------------------- /exercises/040-computePerimeterOfATriangle/app.js: -------------------------------------------------------------------------------- 1 | function computePerimeterOfATriangle(side1, side2, side3) { 2 | // your code here 3 | } 4 | 5 | let output = computePerimeterOfATriangle(6, 4, 10); 6 | console.log(output); // --> 20 7 | -------------------------------------------------------------------------------- /exercises/040-computePerimeterOfATriangle/solution.hide.js: -------------------------------------------------------------------------------- 1 | function computePerimeterOfATriangle(side1, side2, side3) { 2 | // your code here 3 | let perimeter = side1 + side2 + side3; 4 | return perimeter; 5 | } 6 | 7 | let output = computePerimeterOfATriangle(6, 4, 10); 8 | console.log(output); // --> 20 9 | -------------------------------------------------------------------------------- /exercises/041-computeTripledAreaOfARectangle/README.es.md: -------------------------------------------------------------------------------- 1 | # `041` computeTripledAreaOfARectangle 2 | 3 | ## 📝 Instrucciones: 4 | 5 | 1. Escribe una función llamada `computeTripledAreaOfARectangle`. Dado el largo y ancho de un rectángulo, `computeTripledAreaOfARectangle` retorna el área del rectángulo, multiplicado por 3. 6 | 7 | ## 📎 Ejemplo: 8 | 9 | ```Javascript 10 | let output = computeTripledAreaOfARectangle(2, 4); 11 | console.log(output); // --> 24 12 | ``` 13 | -------------------------------------------------------------------------------- /exercises/041-computeTripledAreaOfARectangle/README.md: -------------------------------------------------------------------------------- 1 | # `041` computeTripledAreaOfARectangle 2 | 3 | ## 📝 Instructions: 4 | 5 | 1. Write a function called `computeTripledAreaOfARectangle`. Given the length and width of a rectangle, `computeTripledAreaOfARectangle` returns the rectangle's area, multiplied by 3. 6 | 7 | ## 📎 Example: 8 | 9 | ```Javascript 10 | let output = computeTripledAreaOfARectangle(2, 4); 11 | console.log(output); // --> 24 12 | ``` 13 | -------------------------------------------------------------------------------- /exercises/041-computeTripledAreaOfARectangle/app.js: -------------------------------------------------------------------------------- 1 | function computeTripledAreaOfARectangle(length, width) { 2 | // your code here 3 | 4 | } 5 | 6 | let output = computeTripledAreaOfARectangle(2, 4); 7 | console.log(output); // --> 24 8 | -------------------------------------------------------------------------------- /exercises/041-computeTripledAreaOfARectangle/solution.hide.js: -------------------------------------------------------------------------------- 1 | function computeTripledAreaOfARectangle(length, width) { 2 | // your code here 3 | let area = length * width; 4 | let tripledArea = area * 3; 5 | return tripledArea; 6 | } 7 | 8 | let output = computeTripledAreaOfARectangle(2, 4); 9 | console.log(output); // --> 24 10 | -------------------------------------------------------------------------------- /exercises/042-computePerimeterOfACircle/app.js: -------------------------------------------------------------------------------- 1 | function computePerimeterOfACircle(radius) { 2 | // your code here 3 | 4 | } 5 | 6 | let output = computePerimeterOfACircle(4); 7 | console.log(output); // --> 25.132741228718345 8 | -------------------------------------------------------------------------------- /exercises/042-computePerimeterOfACircle/solution.hide.js: -------------------------------------------------------------------------------- 1 | function computePerimeterOfACircle(radius) { 2 | // your code here 3 | let perimeter = 2 * Math.PI * radius; 4 | return perimeter; 5 | } 6 | 7 | let output = computePerimeterOfACircle(4); 8 | console.log(output); // --> 25.132741228718345 9 | -------------------------------------------------------------------------------- /exercises/043-computeAreaOfACircle/README.es.md: -------------------------------------------------------------------------------- 1 | # `043` computeAreaOfACircle 2 | 3 | ## 📝 Instrucciones: 4 | 5 | 1. Escribe una función llamada `computeAreaOfACircle`. Dado el radio de un círculo, `computeAreaOfACircle` retorna su área. 6 | 7 | ## 📎 Ejemplo: 8 | 9 | ```Javascript 10 | let output = computeAreaOfACircle(4); 11 | console.log(output); // --> 50.26548245743669 12 | ``` 13 | -------------------------------------------------------------------------------- /exercises/043-computeAreaOfACircle/README.md: -------------------------------------------------------------------------------- 1 | # `043` computeAreaOfACircle 2 | 3 | ## 📝 Instructions: 4 | 5 | 1. Write a function called `computeAreaOfACircle`. Given the radius of a circle, `computeAreaOfACircle` returns its area. 6 | 7 | ## 📎 Example: 8 | 9 | ```Javascript 10 | let output = computeAreaOfACircle(4); 11 | console.log(output); // --> 50.26548245743669 12 | ``` 13 | -------------------------------------------------------------------------------- /exercises/043-computeAreaOfACircle/app.js: -------------------------------------------------------------------------------- 1 | function computeAreaOfACircle(radius) { 2 | // your code here 3 | } 4 | 5 | let output = computeAreaOfACircle(4); 6 | console.log(output); // --> 50.26548245743669 7 | -------------------------------------------------------------------------------- /exercises/043-computeAreaOfACircle/solution.hide.js: -------------------------------------------------------------------------------- 1 | function computeAreaOfACircle(radius) { 2 | // your code here 3 | let area = Math.PI * radius * radius; 4 | return area; 5 | } 6 | 7 | let output = computeAreaOfACircle(4); 8 | console.log(output); // --> 50.26548245743669 9 | -------------------------------------------------------------------------------- /exercises/044-computePower/README.es.md: -------------------------------------------------------------------------------- 1 | # `044` computePower 2 | 3 | ## 📝 Instrucciones: 4 | 5 | 1. Escribe una función llamada `computePower`. Dado un número y un exponente, `computePower` retorna el número, elevado al exponente. 6 | 7 | ## 📎 Ejemplo: 8 | 9 | ```Javascript 10 | let output = computePower(2, 3); 11 | console.log(output); // --> 8 12 | ``` 13 | -------------------------------------------------------------------------------- /exercises/044-computePower/README.md: -------------------------------------------------------------------------------- 1 | # `044` computePower 2 | 3 | ## 📝 Instructions: 4 | 5 | 1. Write a function called `computePower`. Given a number and an exponent, `computePower` returns the given number, raised to the given exponent. 6 | 7 | ## 📎 Example: 8 | 9 | ```Javascript 10 | let output = computePower(2, 3); 11 | console.log(output); // --> 8 12 | ``` 13 | -------------------------------------------------------------------------------- /exercises/044-computePower/app.js: -------------------------------------------------------------------------------- 1 | function computePower(num, exponent) { 2 | // your code here 3 | } 4 | 5 | let output = computePower(2, 3); 6 | console.log(output); // --> 8 7 | -------------------------------------------------------------------------------- /exercises/044-computePower/solution.hide.js: -------------------------------------------------------------------------------- 1 | function computePower(num, exponent) { 2 | // your code here 3 | let result = Math.pow(num, exponent); 4 | return result; 5 | } 6 | 7 | let output = computePower(2, 3); 8 | console.log(output); // --> 8 9 | -------------------------------------------------------------------------------- /exercises/045-computeSquareRoot/README.es.md: -------------------------------------------------------------------------------- 1 | # `045` computeSquareRoot 2 | 3 | ## 📝 Instrucciones: 4 | 5 | 1. Escribe una función llamada `computeSquareRoot`. Dado un número, `computeSquareRoot` retorna su raíz cuadrada. 6 | 7 | ## 📎 Ejemplo: 8 | 9 | ```Javascript 10 | let output = computeSquareRoot(9); 11 | console.log(output); // --> 3 12 | ``` 13 | 14 | ## 💡 Pista: 15 | 16 | + Tal vez haya una forma de obtener la raíz cuadrada de un número, intenta buscando aquí: https://developer.mozilla.org/es/docs/Web/JavaScript/Reference/Global_Objects/Math 17 | -------------------------------------------------------------------------------- /exercises/045-computeSquareRoot/README.md: -------------------------------------------------------------------------------- 1 | # `045` computeSquareRoot 2 | 3 | ## 📝 Instructions: 4 | 5 | 1. Write a function called `computeSquareRoot`. Given a number, `computeSquareRoot` returns its square root. 6 | 7 | ## 📎 Example: 8 | 9 | ```Javascript 10 | let output = computeSquareRoot(9); 11 | console.log(output); // --> 3 12 | ``` 13 | 14 | ## 💡 Hint: 15 | 16 | + Maybe there is a way to get the square root of a number, try searching here: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math 17 | -------------------------------------------------------------------------------- /exercises/045-computeSquareRoot/app.js: -------------------------------------------------------------------------------- 1 | function computeSquareRoot(num) { 2 | // your code here 3 | } 4 | 5 | let output = computeSquareRoot(9); 6 | console.log(output); // --> 3 7 | -------------------------------------------------------------------------------- /exercises/045-computeSquareRoot/solution.hide.js: -------------------------------------------------------------------------------- 1 | function computeSquareRoot(num) { 2 | // your code here 3 | let squareRoot = Math.sqrt(num); 4 | return squareRoot; 5 | } 6 | 7 | let output = computeSquareRoot(9); 8 | console.log(output); // --> 3 9 | -------------------------------------------------------------------------------- /exercises/046-doubleSquareRootOf/README.es.md: -------------------------------------------------------------------------------- 1 | # `046` doubleSquareRootOf 2 | 3 | ## 📝 Instrucciones: 4 | 5 | 1. Escribe una función llamada `doubleSquareRootOf`. Dado un número, `doubleSquareRootOf` regresa el doble de su raíz cuadrada. Basicamente retorna la raíz cuadrada del número multiplicada por 2. 6 | 7 | ## 📎 Ejemplo: 8 | 9 | ```Javascript 10 | let output = doubleSquareRootOf(121); 11 | console.log(output); // --> 22 12 | ``` 13 | -------------------------------------------------------------------------------- /exercises/046-doubleSquareRootOf/README.md: -------------------------------------------------------------------------------- 1 | # `046` doubleSquareRootOf 2 | 3 | ## 📝 Instructions: 4 | 5 | 1. Write a function called `doubleSquareRootOf`. Given a number, `doubleSquareRootOf` returns double its square root. It basically returns the square root of the number multiplied by 2. 6 | 7 | ## 📎 Example: 8 | 9 | ```Javascript 10 | let output = doubleSquareRootOf(121); 11 | console.log(output); // --> 22 12 | ``` 13 | -------------------------------------------------------------------------------- /exercises/046-doubleSquareRootOf/app.js: -------------------------------------------------------------------------------- 1 | function doubleSquareRootOf(num) { 2 | // your code here 3 | 4 | } 5 | 6 | let output = doubleSquareRootOf(121); 7 | console.log(output); // --> 22 8 | -------------------------------------------------------------------------------- /exercises/046-doubleSquareRootOf/solution.hide.js: -------------------------------------------------------------------------------- 1 | function doubleSquareRootOf(num) { 2 | // your code here 3 | let squareRoot = Math.sqrt(num); 4 | let result = squareRoot * 2; 5 | return result; 6 | } 7 | 8 | let output = doubleSquareRootOf(121); 9 | console.log(output); // --> 22 10 | -------------------------------------------------------------------------------- /exercises/047-isEitherEvenOrAreBoth7/README.es.md: -------------------------------------------------------------------------------- 1 | # `047` isEitherEvenOrAreBoth7 2 | 3 | ## 📝 Instrucciones: 4 | 5 | 1. Escribe una función llamada `isEitherEvenOrAreBoth7`. Dados dos números, `isEitherEvenOrAreBoth7` retorna `true` si alguno de los parámetros es **par** o los dos son **7**. En caso contrario retorna `false`. 6 | 7 | ## 📎 Ejemplos: 8 | 9 | ```Javascript 10 | let output = isEitherEvenOrAreBoth7(3, 7); 11 | console.log(output); // --> false 12 | 13 | let output = isEitherEvenOrAreBoth7(2, 3); 14 | console.log(output); // --> true 15 | ``` 16 | -------------------------------------------------------------------------------- /exercises/047-isEitherEvenOrAreBoth7/README.md: -------------------------------------------------------------------------------- 1 | # `047` isEitherEvenOrAreBoth7 2 | 3 | ## 📝 Instructions: 4 | 5 | 1. Write a function called `isEitherEvenOrAreBoth7`. Given 2 numbers, `isEitherEvenOrAreBoth7` returns `true` if any parameter is **even** or if both are **7**. If it's not true, it will return `false`. 6 | 7 | ## 📎 Examples: 8 | 9 | ```Javascript 10 | let output = isEitherEvenOrAreBoth7(3, 7); 11 | console.log(output); // --> false 12 | 13 | let output = isEitherEvenOrAreBoth7(2, 3); 14 | console.log(output); // --> true 15 | ``` 16 | -------------------------------------------------------------------------------- /exercises/047-isEitherEvenOrAreBoth7/app.js: -------------------------------------------------------------------------------- 1 | function isEitherEvenOrAreBoth7(num1, num2) { 2 | // your code here 3 | 4 | } 5 | -------------------------------------------------------------------------------- /exercises/047-isEitherEvenOrAreBoth7/solution.hide.js: -------------------------------------------------------------------------------- 1 | function isEitherEvenOrAreBoth7(num1, num2) { 2 | // your code here 3 | if ((num1 % 2 === 0 || num2 % 2 === 0) || (num1 === 7 && num2 === 7)) { 4 | return true; 5 | } else { 6 | return false; 7 | } 8 | } 9 | 10 | let output = isEitherEvenOrAreBoth7(2, 3); 11 | console.log(output); // --> true 12 | -------------------------------------------------------------------------------- /exercises/048-isEitherEvenAndLessThan9/README.md: -------------------------------------------------------------------------------- 1 | # `048` isEitherEvenAndLessThan9 2 | 3 | ## 📝 Instructions: 4 | 5 | 1. Write a function called `isEitherEvenAndLessThan9`. Given 2 numbers, `isEitherEvenAndLessThan9` should return `true` if one of the numbers is **even** and both are **less than 9**, otherwise it must return `false`. 6 | 7 | ## 📎 Examples: 8 | 9 | ```Javascript 10 | let output = isEitherEvenAndLessThan9(2, 4); 11 | console.log(output); // --> true 12 | 13 | let output = isEitherEvenAndLessThan9(72, 2); 14 | console.log(output); // --> false 15 | ``` 16 | -------------------------------------------------------------------------------- /exercises/048-isEitherEvenAndLessThan9/app.js: -------------------------------------------------------------------------------- 1 | function isEitherEvenAndLessThan9(num1, num2) { 2 | // your code here 3 | 4 | } 5 | 6 | let output = isEitherEvenAndLessThan9(2, 4); 7 | console.log(output); // --> true 8 | -------------------------------------------------------------------------------- /exercises/048-isEitherEvenAndLessThan9/solution.hide.js: -------------------------------------------------------------------------------- 1 | function isEitherEvenAndLessThan9(num1, num2) { 2 | // your code here 3 | if ((num1 % 2 === 0 || num2 % 2 === 0) && (num1 < 9 && num2 < 9)) { 4 | return true; 5 | } else { 6 | return false; 7 | } 8 | } 9 | 10 | let output = isEitherEvenAndLessThan9(2, 4); 11 | console.log(output); // --> true 12 | -------------------------------------------------------------------------------- /exercises/049-computeAverageOfNumbers/README.es.md: -------------------------------------------------------------------------------- 1 | # `049` computeAverageOfNumbers 2 | 3 | ## 📝 Instrucciones: 4 | 5 | 1. Escribe una función llamada `computeAverageOfNumbers`. Dado un array de números, `computeAverageOfNumbers` retorna su promedio. 6 | 7 | 8 | ## 📎 Ejemplo: 9 | 10 | ```js 11 | let input = [1, 2, 3, 4, 5]; 12 | let output = computeAverageOfNumbers(input); 13 | console.log(output); // --> 3 14 | ``` 15 | 16 | ## 💡 Pista: 17 | 18 | + Si el array dado se encuentra vacío, debería retornar `0`. 19 | -------------------------------------------------------------------------------- /exercises/049-computeAverageOfNumbers/README.md: -------------------------------------------------------------------------------- 1 | # `049` computeAverageOfNumbers 2 | 3 | ## 📝 Instructions: 4 | 5 | 1. Write a function called `computeAverageOfNumbers`. Given an array of numbers, `computeAverageOfNumbers` returns their average. 6 | 7 | ## 📎 Example: 8 | 9 | ```js 10 | let input = [1, 2, 3, 4, 5]; 11 | let output = computeAverageOfNumbers(input); 12 | console.log(output); // --> 3 13 | ``` 14 | 15 | ## 💡 Hint: 16 | 17 | + If given an empty array, it should return `0`. 18 | -------------------------------------------------------------------------------- /exercises/049-computeAverageOfNumbers/app.js: -------------------------------------------------------------------------------- 1 | // Write your function here 2 | -------------------------------------------------------------------------------- /exercises/049-computeAverageOfNumbers/solution.hide.js: -------------------------------------------------------------------------------- 1 | function computeAverageOfNumbers(nums) { 2 | if (nums.length == 0) return 0; 3 | 4 | let total = 0; 5 | for (let i = 0; i < nums.length; i++) { 6 | total += nums[i]; 7 | } 8 | let avg = total / nums.length; 9 | return avg; 10 | } 11 | -------------------------------------------------------------------------------- /exercises/050-getNthElement/README.es.md: -------------------------------------------------------------------------------- 1 | # `050` getNthElement 2 | 3 | ## 📝 Instrucciones: 4 | 5 | 1. Escribe una función llamada `getNthElement`. Dado un array y un número entero, `getNthElement` retorna el elemento del array ubicado dentro de la posición dada. 6 | 7 | ## 📎 Ejemplo: 8 | 9 | ```Javascript 10 | let output = getNthElement([1, 3, 5], 1); 11 | console.log(output); // --> 3 12 | ``` 13 | -------------------------------------------------------------------------------- /exercises/050-getNthElement/README.md: -------------------------------------------------------------------------------- 1 | # `050` getNthElement 2 | 3 | ## 📝 Instructions: 4 | 5 | 1. Write a function called `getNthElement`. Given an array and an integer, `getNthElement` returns the element at the given integer, within the given array. 6 | 7 | ## 📎 Example: 8 | 9 | ```Javascript 10 | let output = getNthElement([1, 3, 5], 1); 11 | console.log(output); // --> 3 12 | ``` 13 | -------------------------------------------------------------------------------- /exercises/050-getNthElement/app.js: -------------------------------------------------------------------------------- 1 | function getNthElement(array, n) { 2 | // Add your code after this line 3 | 4 | } 5 | -------------------------------------------------------------------------------- /exercises/050-getNthElement/solution.hide.js: -------------------------------------------------------------------------------- 1 | function getNthElement(array, n) { 2 | // Add your code after this line 3 | return array[n] 4 | } 5 | -------------------------------------------------------------------------------- /exercises/051-getFirstElement/README.es.md: -------------------------------------------------------------------------------- 1 | # `051` getFirstElement 2 | 3 | ## 📝 Instrucciones: 4 | 5 | 1. Escribe una función llamada `getFirstElement`. Dado un array, `getFirstElement` regresa el primer elemento del array. 6 | 7 | 8 | ## 📎 Ejemplo: 9 | 10 | ```Javascript 11 | let output = getFirstElement([1, 2, 3, 4, 5]); 12 | console.log(output); // --> 1 13 | ``` 14 | -------------------------------------------------------------------------------- /exercises/051-getFirstElement/README.md: -------------------------------------------------------------------------------- 1 | # `051` getFirstElement 2 | 3 | ## 📝 Instructions: 4 | 5 | 1. Write a function called `getFirstElement`. Given an array, `getFirstElement` returns the first element of the given array. 6 | 7 | 8 | ## 📎 Example: 9 | 10 | ```Javascript 11 | let output = getFirstElement([1, 2, 3, 4, 5]); 12 | console.log(output); // --> 1 13 | ``` 14 | -------------------------------------------------------------------------------- /exercises/051-getFirstElement/app.js: -------------------------------------------------------------------------------- 1 | function getFirstElement(array) { 2 | // Add your code after this line 3 | 4 | } 5 | 6 | let output = getFirstElement([1, 2, 3, 4, 5]); 7 | console.log(output); // --> 1 -------------------------------------------------------------------------------- /exercises/051-getFirstElement/solution.hide.js: -------------------------------------------------------------------------------- 1 | function getFirstElement(array) { 2 | // Add your code after this line 3 | return array[0] 4 | } 5 | 6 | let output = getFirstElement([1, 2, 3, 4, 5]); 7 | console.log(output); // --> 1 8 | -------------------------------------------------------------------------------- /exercises/052-getLastElement/README.es.md: -------------------------------------------------------------------------------- 1 | # `052` getLastElement 2 | 3 | ## 📝 Instrucciones: 4 | 5 | 1. Escribe una función llamada `getLastElement`. Dado un array, `getLastElement` retorna el último elemento del array. 6 | 7 | ## 📎 Ejemplo: 8 | 9 | ```Javascript 10 | let output = getLastElement([1, 2, 3, 4]); 11 | console.log(output); // --> 4 12 | ``` 13 | 14 | ## 💡 Pistas: 15 | 16 | + La última posición en un array es: `length - 1`. 17 | -------------------------------------------------------------------------------- /exercises/052-getLastElement/README.md: -------------------------------------------------------------------------------- 1 | # `052` getLastElement 2 | 3 | ## 📝 Instructions: 4 | 5 | 1. Write a function called `getLastElement`. Given an array, `getLastElement` returns the last element of the given array. 6 | 7 | ## 📎 Example: 8 | 9 | ```Javascript 10 | let output = getLastElement([1, 2, 3, 4]); 11 | console.log(output); // --> 4 12 | ``` 13 | 14 | ## 💡 Hints: 15 | 16 | + The last position in any array is: `length - 1`. 17 | -------------------------------------------------------------------------------- /exercises/052-getLastElement/app.js: -------------------------------------------------------------------------------- 1 | function getLastElement(array) { 2 | // Add your code after this line 3 | 4 | } 5 | -------------------------------------------------------------------------------- /exercises/052-getLastElement/solution.hide.js: -------------------------------------------------------------------------------- 1 | function getLastElement(array) { 2 | // Add your code after this line 3 | return array[array.length - 1] 4 | } 5 | -------------------------------------------------------------------------------- /exercises/053-addToFront/README.es.md: -------------------------------------------------------------------------------- 1 | # `053` addToFront 2 | 3 | ## 📝 Instrucciones: 4 | 5 | 1. Escribe una función llamada `addToFront`. Dado un array y un elemento, `addToFront` añade el elemento al frente del array, y regresa el array dado. 6 | 7 | ## 📎 Ejemplo: 8 | 9 | ```Javascript 10 | let output = addToFront([1, 2], 3); 11 | console.log(output); // --> [3, 1, 2] 12 | ``` 13 | 14 | ## 💡 Pistas: 15 | 16 | + Debe devolver el MISMO array, no uno nuevo. 17 | 18 | + Busca en Google el método `unshift()`. 19 | -------------------------------------------------------------------------------- /exercises/053-addToFront/README.md: -------------------------------------------------------------------------------- 1 | # `053` addToFront 2 | 3 | ## 📝 Instructions: 4 | 5 | 1. Write a function called `addToFront`. Given an array and an element, `addToFront` adds the given element to the front of the given array, and returns the given array. 6 | 7 | ## 📎 Example: 8 | 9 | ```Javascript 10 | let output = addToFront([1, 2], 3); 11 | console.log(output); // --> [3, 1, 2] 12 | ``` 13 | 14 | ## 💡 Hint: 15 | 16 | + It should be the SAME array, not a new array. 17 | 18 | + Google the method `unshift()`. 19 | -------------------------------------------------------------------------------- /exercises/053-addToFront/app.js: -------------------------------------------------------------------------------- 1 | function addToFront(arr, element) { 2 | // your code here 3 | 4 | } 5 | 6 | let output = addToFront([1, 2], 3); 7 | console.log(output); // -> [3, 1, 2] 8 | -------------------------------------------------------------------------------- /exercises/053-addToFront/solution.hide.js: -------------------------------------------------------------------------------- 1 | function addToFront(arr, element) { 2 | // your code here 3 | arr.unshift(element); 4 | return arr; 5 | } 6 | 7 | let output = addToFront([1, 2], 3); 8 | console.log(output); // -> [3, 1, 2] 9 | -------------------------------------------------------------------------------- /exercises/054-addToBack/README.es.md: -------------------------------------------------------------------------------- 1 | # `054` addToBack 2 | 3 | ## 📝 Instrucciones: 4 | 5 | 1. Escribe una función llamada `addToBack`. Dado un array y un elemento, `addToBack` retorna el array con el elemento añadido al final. 6 | 7 | ## 📎 Ejemplo: 8 | 9 | ```Javascript 10 | let output = addToBack([1, 2], 3); 11 | console.log(output); // --> [1, 2, 3] 12 | ``` 13 | 14 | ## 💡 Pistas: 15 | 16 | + Debe devolver el MISMO array, no uno nuevo. 17 | 18 | + Intenta buscar en Google "cómo añadir un elemento al final de un array". 19 | -------------------------------------------------------------------------------- /exercises/054-addToBack/README.md: -------------------------------------------------------------------------------- 1 | # `054` addToBack 2 | 3 | ## 📝 Instructions: 4 | 5 | 1. Write a function called `addToBack`. Given an array and an element, `addToBack` returns the given array with the given element added at the end. 6 | 7 | ## 📎 Example: 8 | 9 | ```Javascript 10 | let output = addToBack([1, 2], 3); 11 | console.log(output); // --> [1, 2, 3] 12 | ``` 13 | 14 | ## 💡 Hints: 15 | 16 | + It should be the SAME array, not a new array. 17 | 18 | + Try to Google "how to add an element at the end of an array". 19 | -------------------------------------------------------------------------------- /exercises/054-addToBack/app.js: -------------------------------------------------------------------------------- 1 | function addToBack(arr, element) { 2 | // your code here 3 | 4 | } 5 | 6 | let output = addToBack([1, 2], 3); 7 | console.log(output); // -> [1, 2, 3] 8 | -------------------------------------------------------------------------------- /exercises/054-addToBack/solution.hide.js: -------------------------------------------------------------------------------- 1 | function addToBack(arr, element) { 2 | // your code here 3 | arr.push(element); 4 | return arr; 5 | } 6 | 7 | let output = addToBack([1, 2], 3); 8 | console.log(output); // -> [1, 2, 3] 9 | -------------------------------------------------------------------------------- /exercises/055-joinArrays/README.es.md: -------------------------------------------------------------------------------- 1 | # `055` joinArrays 2 | 3 | ## 📝 Instrucciones: 4 | 5 | 1. Escribe una función llamada `joinArrays`. Dados dos arrays, `joinArrays` retorna un array con los elementos de `arr1`, seguido por los elementos de `arr2` en orden. 6 | 7 | ## 📎 Ejemplo: 8 | 9 | ```Javascript 10 | let output = joinArrays([1, 2], [3, 4]); 11 | console.log(output); // --> [1, 2, 3, 4] 12 | ``` 13 | 14 | ## 💡 Pista: 15 | 16 | + Deberías estar familiarizado con el método `concat()` para este problema. 17 | -------------------------------------------------------------------------------- /exercises/055-joinArrays/README.md: -------------------------------------------------------------------------------- 1 | # `055` joinArrays 2 | 3 | ## 📝 Instructions: 4 | 5 | 1. Write a function called `joinArrays`. Given 2 arrays, `joinArrays` returns an array with the elements of `arr1`, followed by the elements of `arr2` in order. 6 | 7 | ## 📎 Example: 8 | 9 | ```Javascript 10 | let output = joinArrays([1, 2], [3, 4]); 11 | console.log(output); // --> [1, 2, 3, 4] 12 | ``` 13 | ## 💡 Hint: 14 | 15 | + You should use the `concat()` method. 16 | -------------------------------------------------------------------------------- /exercises/055-joinArrays/app.js: -------------------------------------------------------------------------------- 1 | function joinArrays(arr1, arr2) { 2 | // your code here 3 | 4 | } 5 | 6 | let output = joinArrays([1, 2], [3, 4]); 7 | console.log(output); // --> [1, 2, 3, 4] 8 | -------------------------------------------------------------------------------- /exercises/055-joinArrays/solution.hide.js: -------------------------------------------------------------------------------- 1 | function joinArrays(arr1, arr2) { 2 | // your code here 3 | let joinedArray = arr1.concat(arr2); 4 | return joinedArray; 5 | } 6 | 7 | let output = joinArrays([1, 2], [3, 4]); 8 | console.log(output); // --> [1, 2, 3, 4] 9 | -------------------------------------------------------------------------------- /exercises/056-getElementsAfter/README.es.md: -------------------------------------------------------------------------------- 1 | # `056` getElementsAfter 2 | 3 | ## 📝 Instrucciones: 4 | 5 | 1. Escribe una función llamada `getElementsAfter`. Dado un array y un índice (index), `getElementsAfter` retorna un nuevo array con todos los elementos que estén después (pero sin incluir) el índice dado. 6 | 7 | ## 📎 Ejemplo: 8 | 9 | ```Javascript 10 | let output = getElementsAfter(['a', 'b', 'c', 'd', 'e'], 2); 11 | console.log(output); // --> ['d', 'e'] 12 | ``` 13 | 14 | ## 💡 Pista: 15 | 16 | + Para esto el método `slice()` puede ser útil. 17 | -------------------------------------------------------------------------------- /exercises/056-getElementsAfter/README.md: -------------------------------------------------------------------------------- 1 | # `056` getElementsAfter 2 | 3 | ## 📝 Instructions: 4 | 5 | 1. Write a function called `getElementsAfter`. Given an array and an index, `getElementsAfter` returns a new array with all the elements after (but not including) the given index. 6 | 7 | ## 📎 Example: 8 | 9 | ```Javascript 10 | let output = getElementsAfter(['a', 'b', 'c', 'd', 'e'], 2); 11 | console.log(output); // --> ['d', 'e'] 12 | ``` 13 | 14 | ## 💡 Hint: 15 | 16 | + For this one the method `slice()` might be useful. 17 | -------------------------------------------------------------------------------- /exercises/056-getElementsAfter/app.js: -------------------------------------------------------------------------------- 1 | function getElementsAfter(array, n) { 2 | // your code here 3 | 4 | } 5 | 6 | let output = getElementsAfter(['a', 'b', 'c', 'd', 'e'], 2); 7 | console.log(output); // --> ['d', 'e'] 8 | -------------------------------------------------------------------------------- /exercises/056-getElementsAfter/solution.hide.js: -------------------------------------------------------------------------------- 1 | function getElementsAfter(array, n) { 2 | // your code here 3 | let elementsAfter = array.slice(n + 1); 4 | return elementsAfter; 5 | } 6 | 7 | let output = getElementsAfter(['a', 'b', 'c', 'd', 'e'], 2); 8 | console.log(output); // --> ['d', 'e'] 9 | -------------------------------------------------------------------------------- /exercises/057-getElementsUpTo/README.es.md: -------------------------------------------------------------------------------- 1 | # `057` getElementsUpTo 2 | 3 | ## 📝 Instrucciones: 4 | 5 | 1. Escribe una función llamada `getElementsUpTo`. Dados un array y un índice, `getElementsUpTo` retorna un array con todos los elementos hasta (pero sin incluir) el elemento en el índice dado. 6 | 7 | ## 📎 Ejemplo: 8 | 9 | ```Javascript 10 | let output = getElementsUpTo(['a', 'b', 'c', 'd', 'e'], 3) 11 | console.log(output); // --> ['a', 'b', 'c'] 12 | ``` 13 | ## 💡 Pista: 14 | 15 | + Para poder hacer este ejercicio debes estar familiarizado con el método `slice()`. 16 | -------------------------------------------------------------------------------- /exercises/057-getElementsUpTo/README.md: -------------------------------------------------------------------------------- 1 | # `057` getElementsUpTo 2 | 3 | ## 📝 Instructions: 4 | 5 | 1. Write a function called `getElementsUpTo`. Given an array and an index, `getElementsUpTo` returns an array with all the elements up until, but not including, the element at the given index. 6 | 7 | ## 📎 Example: 8 | 9 | ```Javascript 10 | let output = getElementsUpTo(['a', 'b', 'c', 'd', 'e'], 3) 11 | console.log(output); // --> ['a', 'b', 'c'] 12 | ``` 13 | 14 | ## 💡 Hint: 15 | 16 | + In order to do this you should be familiar with the `slice()` method. 17 | -------------------------------------------------------------------------------- /exercises/057-getElementsUpTo/app.js: -------------------------------------------------------------------------------- 1 | function getElementsUpTo(array, n) { 2 | // your code here 3 | 4 | } 5 | 6 | let output = getElementsUpTo(['a', 'b', 'c', 'd', 'e'], 3) 7 | console.log(output); // --> ['a', 'b', 'c'] 8 | -------------------------------------------------------------------------------- /exercises/057-getElementsUpTo/solution.hide.js: -------------------------------------------------------------------------------- 1 | function getElementsUpTo(array, n) { 2 | // your code here 3 | let elementsUpTo = array.slice(0, n); 4 | return elementsUpTo; 5 | } 6 | 7 | let output = getElementsUpTo(['a', 'b', 'c', 'd', 'e'], 3) 8 | console.log(output); // --> ['a', 'b', 'c'] 9 | -------------------------------------------------------------------------------- /exercises/058-removeFromFront/README.md: -------------------------------------------------------------------------------- 1 | # `058` removeFromFront 2 | 3 | ## 📝 Instructions: 4 | 5 | 1. Write a function called `removeFromFront`. Given an array, `removeFromFront` returns the **SAME** array with its first element removed. 6 | 7 | ## 📎 Example: 8 | 9 | ```Javascript 10 | let output = removeFromFront([1, 2, 3]); 11 | console.log(output); // --> [2, 3] 12 | ``` 13 | 14 | ## 💡 Hints: 15 | 16 | + Remember the method `slice()` does **NOT** modify the given array, but it creates a copy of it. 17 | 18 | + You should be familiar with the method `shift()`. 19 | -------------------------------------------------------------------------------- /exercises/058-removeFromFront/app.js: -------------------------------------------------------------------------------- 1 | function removeFromFront(arr) { 2 | // your code here 3 | 4 | } 5 | 6 | let output = removeFromFront([1, 2, 3]); 7 | console.log(output); // --> [2, 3] 8 | -------------------------------------------------------------------------------- /exercises/058-removeFromFront/solution.hide.js: -------------------------------------------------------------------------------- 1 | function removeFromFront(arr) { 2 | // your code here 3 | arr.shift(); 4 | return arr; 5 | } 6 | 7 | let output = removeFromFront([1, 2, 3]); 8 | console.log(output); // --> [2, 3] 9 | -------------------------------------------------------------------------------- /exercises/059-removeFromBack/README.es.md: -------------------------------------------------------------------------------- 1 | # `059` removeFromBack 2 | 3 | ## 📝 Instrucciones: 4 | 5 | 1. Escribe una función llamada `removeFromBack`. Dado un array, `removeFromBack` retorna el array con su último elemento eliminado. 6 | 7 | ## 📎 Ejemplo: 8 | 9 | ```Javascript 10 | let output = removeFromBack([1, 2, 3]); 11 | console.log(output); // --> [1, 2] 12 | ``` 13 | 14 | ## 💡 Pista: 15 | 16 | + Debes estar familiarizado con el método `pop()`. 17 | -------------------------------------------------------------------------------- /exercises/059-removeFromBack/README.md: -------------------------------------------------------------------------------- 1 | # `059` removeFromBack 2 | 3 | ## 📝 Instructions: 4 | 5 | 1. Write a function called `removeFromBack`. Given an array, `removeFromBack` returns the array with its last element removed. 6 | 7 | ## 📎 Example: 8 | 9 | ```Javascript 10 | let output = removeFromBack([1, 2, 3]); 11 | console.log(output); // --> [1, 2] 12 | ``` 13 | 14 | ## 💡 Hint: 15 | 16 | + You should be familiar with the `pop()` method. 17 | -------------------------------------------------------------------------------- /exercises/059-removeFromBack/app.js: -------------------------------------------------------------------------------- 1 | function removeFromBack(arr) { 2 | // your code here 3 | 4 | } 5 | 6 | let output = removeFromBack([1, 2, 3]); 7 | console.log(output); // --> [1, 2] 8 | -------------------------------------------------------------------------------- /exercises/059-removeFromBack/solution.hide.js: -------------------------------------------------------------------------------- 1 | function removeFromBack(arr) { 2 | // your code here 3 | arr.pop(); 4 | return arr; 5 | } 6 | 7 | let output = removeFromBack([1, 2, 3]); 8 | console.log(output); // --> [1, 2] 9 | -------------------------------------------------------------------------------- /exercises/060-removeFromFrontOfNew/app.js: -------------------------------------------------------------------------------- 1 | function removeFromFrontOfNew(arr) { 2 | // your code here 3 | 4 | } 5 | 6 | let arr = [1, 2, 3]; 7 | let output = removeFromFrontOfNew(arr); 8 | console.log(output); // --> [2, 3] 9 | console.log(arr); // --> [1, 2, 3] 10 | -------------------------------------------------------------------------------- /exercises/060-removeFromFrontOfNew/solution.hide.js: -------------------------------------------------------------------------------- 1 | function removeFromFrontOfNew(arr) { 2 | // your code here 3 | return arr.slice(1); 4 | } 5 | 6 | let arr = [1, 2, 3]; 7 | let output = removeFromFrontOfNew(arr); 8 | console.log(output); // --> [2, 3] 9 | console.log(arr); // --> [1, 2, 3] 10 | -------------------------------------------------------------------------------- /exercises/061-removeFromBackOfNew/app.js: -------------------------------------------------------------------------------- 1 | function removeFromBackOfNew(arr) { 2 | // your code here 3 | 4 | } 5 | 6 | let arr = [1, 2, 3]; 7 | let output = removeFromBackOfNew(arr); 8 | console.log(output); // --> [1, 2] 9 | console.log(arr); // --> [1, 2, 3] 10 | -------------------------------------------------------------------------------- /exercises/061-removeFromBackOfNew/solution.hide.js: -------------------------------------------------------------------------------- 1 | function removeFromBackOfNew(arr) { 2 | // your code here 3 | return arr.slice(0, arr.length - 1); 4 | } 5 | 6 | let arr = [1, 2, 3]; 7 | let output = removeFromBackOfNew(arr); 8 | console.log(output); // --> [1, 2] 9 | console.log(arr); // --> [1, 2, 3] 10 | -------------------------------------------------------------------------------- /exercises/062-countCharacter/README.es.md: -------------------------------------------------------------------------------- 1 | # `062` countCharacter 2 | 3 | ## 📝 Instrucciones: 4 | 5 | 1. Escribe una función llamada `countCharacter`. Dados un string y un caracter, `countCharacter` retorna el número de repeticiones del caracter dado en el string. 6 | 7 | ## 📎 Ejemplo: 8 | 9 | ```Javascript 10 | let output = countCharacter('I am a hacker', 'a'); 11 | console.log(output); // --> 3 12 | ``` 13 | 14 | ## 💡 Pista: 15 | 16 | + Tienes que iterar (usar un loop) en el string dado para completar este ejercicio, si no recuerdas cómo, Google es tu amigo 😎 17 | -------------------------------------------------------------------------------- /exercises/062-countCharacter/README.md: -------------------------------------------------------------------------------- 1 | # `062` countCharacter 2 | 3 | ## 📝 Instructions: 4 | 5 | 1. Write a function called `countCharacter`. Given a string input and a character, `countCharacter` returns the number of occurences of a given character in the given string. 6 | 7 | ## 📎 Example: 8 | 9 | ```Javascript 10 | let output = countCharacter('I am a hacker', 'a'); 11 | console.log(output); // --> 3 12 | ``` 13 | 14 | ## 💡 Hint: 15 | 16 | + You have to loop through the whole string for this exercise, if you don't remember how, Google is your friend 😎 17 | -------------------------------------------------------------------------------- /exercises/062-countCharacter/app.js: -------------------------------------------------------------------------------- 1 | function countCharacter(str, char) { 2 | // your code here 3 | 4 | } 5 | 6 | let output = countCharacter('I am a hacker', 'a'); 7 | console.log(output); // --> 3 8 | -------------------------------------------------------------------------------- /exercises/062-countCharacter/solution.hide.js: -------------------------------------------------------------------------------- 1 | function countCharacter(str, char) { 2 | // your code here 3 | let count = 0; 4 | for (let i = 0; i < str.length; i++) { 5 | if (str[i] === char) { 6 | count++; 7 | } 8 | } 9 | return count; 10 | } 11 | 12 | let output = countCharacter('I am a hacker', 'a'); 13 | console.log(output); // --> 3 14 | -------------------------------------------------------------------------------- /exercises/063-getAllLetters/README.es.md: -------------------------------------------------------------------------------- 1 | # `063` getAllLetters 2 | 3 | ## 📝 Instrucciones: 4 | 5 | 1. Escribe una función llamada `getAllLetters`. Dado una palabra, `getAllLetters` retorna un array que contenga todos los caracteres de la palabra. 6 | 7 | ## 📎 Ejemplo: 8 | 9 | ```Javascript 10 | let output = getAllLetters('Radagast'); 11 | console.log(output); // --> ['R', 'a', 'd', 'a', 'g', 'a', 's', 't'] 12 | ``` 13 | 14 | ## 💡 Pista: 15 | 16 | + Si se da un string vacío, debe retornar un array vacío. 17 | -------------------------------------------------------------------------------- /exercises/063-getAllLetters/README.md: -------------------------------------------------------------------------------- 1 | # `063` getAllLetters 2 | 3 | ## 📝 Instructions: 4 | 5 | 1. Write a function called `getAllLetters`. Given a word, `getAllLetters` returns an array containing every character in the word. 6 | 7 | ## 📎 Example: 8 | 9 | ```Javascript 10 | let output = getAllLetters('Radagast'); 11 | console.log(output); // --> ['R', 'a', 'd', 'a', 'g', 'a', 's', 't'] 12 | ``` 13 | 14 | ## 💡 Hint: 15 | 16 | + If given an empty string, it should return an empty array. 17 | -------------------------------------------------------------------------------- /exercises/063-getAllLetters/app.js: -------------------------------------------------------------------------------- 1 | function getAllLetters(str) { 2 | // your code here 3 | 4 | } 5 | 6 | let output = getAllLetters('Radagast'); 7 | console.log(output); // --> ['R', 'a', 'd', 'a', 'g', 'a', 's', 't'] 8 | -------------------------------------------------------------------------------- /exercises/063-getAllLetters/solution.hide.js: -------------------------------------------------------------------------------- 1 | function getAllLetters(str) { 2 | // your code here 3 | let letters = []; 4 | for (let i = 0; i < str.length; i++) { 5 | letters.push(str[i]); 6 | } 7 | return letters; 8 | } 9 | 10 | let output = getAllLetters('Radagast'); 11 | console.log(output); // --> ['R', 'a', 'd', 'a', 'g', 'a', 's', 't'] 12 | -------------------------------------------------------------------------------- /exercises/064-getAllWords/README.es.md: -------------------------------------------------------------------------------- 1 | # `064` getAllWords 2 | 3 | ## 📝 Instrucciones: 4 | 5 | 1. Escribe una función llamada `getAllWords`. Dado una oración, `getAllWords` retorna un array que contenga cada palabra de la oración. 6 | 7 | ## 📎 Ejemplo: 8 | 9 | ```Javascript 10 | let output = getAllWords('Radagast the Brown'); 11 | console.log(output); // --> ['Radagast', 'the', 'Brown'] 12 | ``` 13 | 14 | ## 💡 Pista: 15 | 16 | + Investiga el método `split()`. 17 | -------------------------------------------------------------------------------- /exercises/064-getAllWords/README.md: -------------------------------------------------------------------------------- 1 | # `064` getAllWords 2 | 3 | ## 📝 Instructions: 4 | 5 | Write a function called `getAllWords`. Given a sentence, `getAllWords` returns an array containing every word in the sentence. 6 | 7 | ## 📎 Example: 8 | 9 | ```Javascript 10 | let output = getAllWords('Radagast the Brown'); 11 | console.log(output); // --> ['Radagast', 'the', 'Brown'] 12 | ``` 13 | 14 | ## 💡 Hint: 15 | 16 | + Investigate the `split()` method. 17 | -------------------------------------------------------------------------------- /exercises/064-getAllWords/app.js: -------------------------------------------------------------------------------- 1 | function getAllWords(str) { 2 | // your code here 3 | 4 | } 5 | 6 | let output = getAllWords('Radagast the Brown'); 7 | console.log(output); // --> ['Radagast', 'the', 'Brown'] 8 | -------------------------------------------------------------------------------- /exercises/064-getAllWords/solution.hide.js: -------------------------------------------------------------------------------- 1 | function getAllWords(str) { 2 | // your code here 3 | let words = str.split(' '); 4 | return words; 5 | } 6 | 7 | let output = getAllWords('Radagast the Brown'); 8 | console.log(output); // --> ['Radagast', 'the', 'Brown'] 9 | -------------------------------------------------------------------------------- /exercises/065-or/app.js: -------------------------------------------------------------------------------- 1 | function or(expression1, expression2) { 2 | // your code here 3 | 4 | } 5 | 6 | let output = or(true, false); 7 | console.log(output); // --> true; 8 | -------------------------------------------------------------------------------- /exercises/065-or/solution.hide.js: -------------------------------------------------------------------------------- 1 | function or(expression1, expression2) { 2 | // your code here 3 | return !(!expression1 && !expression2); 4 | } 5 | 6 | let output = or(true, false); 7 | console.log(output); // --> true; 8 | -------------------------------------------------------------------------------- /exercises/066-extend/app.js: -------------------------------------------------------------------------------- 1 | let obj1 = { 2 | a: 1, 3 | b: 2 4 | }; 5 | let obj2 = { 6 | b: 4, 7 | c: 3 8 | }; 9 | 10 | function extend(obj1, obj2) { 11 | // your code here 12 | 13 | } -------------------------------------------------------------------------------- /exercises/066-extend/solution.hide.js: -------------------------------------------------------------------------------- 1 | let obj1 = { 2 | a: 1, 3 | b: 2 4 | }; 5 | let obj2 = { 6 | b: 4, 7 | c: 3 8 | }; 9 | 10 | function extend(obj1, obj2) { 11 | // your code here 12 | for (let key in obj2) { 13 | if (!(key in obj1)) { 14 | obj1[key] = obj2[key]; 15 | } 16 | } 17 | return obj1; 18 | } 19 | -------------------------------------------------------------------------------- /exercises/067-removeNumbersLargerThan/app.js: -------------------------------------------------------------------------------- 1 | let obj = { 2 | a: 8, 3 | b: 2, 4 | c: 'montana' 5 | } 6 | 7 | function removeNumbersLargerThan(num, obj) { 8 | // your code here 9 | 10 | } 11 | -------------------------------------------------------------------------------- /exercises/067-removeNumbersLargerThan/solution.hide.js: -------------------------------------------------------------------------------- 1 | let obj = { 2 | a: 8, 3 | b: 2, 4 | c: 'montana' 5 | } 6 | 7 | function removeNumbersLargerThan(num, obj) { 8 | // your code here 9 | for (let key in obj) { 10 | if (typeof obj[key] === 'number' && obj[key] > num) { 11 | delete obj[key]; 12 | } 13 | } 14 | return obj; 15 | } 16 | -------------------------------------------------------------------------------- /exercises/068-removeNumbersLessThan/README.es.md: -------------------------------------------------------------------------------- 1 | # `068` removeNumbersLessThan 2 | 3 | ## 📝 Instrucciones: 4 | 5 | 1. Escribe una función llamada `removeNumbersLessThan`. Dado un número y un objeto, `removeNumbersLessThan` elimina cualquier propiedad cuyos valores sean números menores que el número dado. 6 | 7 | ## 📎 Ejemplo: 8 | 9 | ```Javascript 10 | let obj = { 11 | a: 8, 12 | b: 2, 13 | c: 'montana' 14 | } 15 | removeNumbersLessThan(5, obj); 16 | console.log(obj); // --> { a: 8, c: 'montana' } 17 | ``` 18 | -------------------------------------------------------------------------------- /exercises/068-removeNumbersLessThan/README.md: -------------------------------------------------------------------------------- 1 | # `068` removeNumbersLessThan 2 | 3 | ## 📝 Instructions: 4 | 5 | 1. Write a function called `removeNumbersLessThan`. Given a number and an object, `removeNumbersLessThan` removes any property whose values are numbers less than the given number. 6 | 7 | ## 📎 Example: 8 | 9 | ```Javascript 10 | let obj = { 11 | a: 8, 12 | b: 2, 13 | c: 'montana' 14 | } 15 | removeNumbersLessThan(5, obj); 16 | console.log(obj); // --> { a: 8, c: 'montana' } 17 | ``` 18 | -------------------------------------------------------------------------------- /exercises/068-removeNumbersLessThan/app.js: -------------------------------------------------------------------------------- 1 | let obj = { 2 | a: 8, 3 | b: 2, 4 | c: 'montana' 5 | } 6 | 7 | function removeNumbersLessThan(num, obj) { 8 | // your code here 9 | 10 | } 11 | -------------------------------------------------------------------------------- /exercises/068-removeNumbersLessThan/solution.hide.js: -------------------------------------------------------------------------------- 1 | let obj = { 2 | a: 8, 3 | b: 2, 4 | c: 'montana' 5 | } 6 | 7 | function removeNumbersLessThan(num, obj) { 8 | // your code here 9 | for (let key in obj) { 10 | if (typeof obj[key] === 'number' && obj[key] < num) { 11 | delete obj[key]; 12 | } 13 | } 14 | return obj; 15 | } 16 | -------------------------------------------------------------------------------- /exercises/069-removeStringValuesLongerThan/app.js: -------------------------------------------------------------------------------- 1 | function removeStringValuesLongerThan(num, obj) { 2 | // your code here 3 | 4 | } 5 | 6 | let obj = { 7 | name: 'Montana', 8 | age: 20, 9 | location: 'Texas', 10 | }; 11 | 12 | removeStringValuesLongerThan(6, obj); 13 | console.log(obj); // { age: 20, location: 'Texas' } 14 | -------------------------------------------------------------------------------- /exercises/069-removeStringValuesLongerThan/solution.hide.js: -------------------------------------------------------------------------------- 1 | function removeStringValuesLongerThan(num, obj) { 2 | // your code here 3 | for (let key in obj) { 4 | if (typeof obj[key] === 'string' && obj[key].length > num) { 5 | delete obj[key]; 6 | } 7 | } 8 | return obj; 9 | } 10 | 11 | let obj = { 12 | name: 'Montana', 13 | age: 20, 14 | location: 'Texas', 15 | }; 16 | 17 | removeStringValuesLongerThan(6, obj); 18 | console.log(obj); // { age: 20, location: 'Texas' } 19 | -------------------------------------------------------------------------------- /exercises/070-removeEvenValues/README.md: -------------------------------------------------------------------------------- 1 | # `070` removeEvenValues 2 | 3 | ## 📝 Instructions: 4 | 5 | 1. Write a function called `removeEvenValues`. Given any object, `removeEvenValues` removes any properties whose values are even numbers. 6 | 7 | ## 📎 Example: 8 | 9 | ```Javascript 10 | let obj = { 11 | a: 2, 12 | b: 3, 13 | c: 4 14 | }; 15 | removeEvenValues(obj); 16 | console.log(obj); // --> { b: 3 } 17 | ``` 18 | 19 | ## 💡 Hint: 20 | 21 | + You must modify the given object, do not hard code the desired result. 22 | -------------------------------------------------------------------------------- /exercises/070-removeEvenValues/app.js: -------------------------------------------------------------------------------- 1 | function removeEvenValues(obj) { 2 | // your code here 3 | 4 | } 5 | 6 | let obj = { 7 | a: 2, 8 | b: 3, 9 | c: 4 10 | }; 11 | removeEvenValues(obj); 12 | console.log(obj); // --> { b: 3 } 13 | -------------------------------------------------------------------------------- /exercises/070-removeEvenValues/solution.hide.js: -------------------------------------------------------------------------------- 1 | function removeEvenValues(obj) { 2 | // your code here 3 | for (let key in obj) { 4 | if (typeof obj[key] === 'number' && obj[key] % 2 === 0) { 5 | delete obj[key]; 6 | } 7 | } 8 | return obj; 9 | } 10 | 11 | let obj = { 12 | a: 2, 13 | b: 3, 14 | c: 4 15 | }; 16 | removeEvenValues(obj); 17 | console.log(obj); // --> { b: 3 } 18 | -------------------------------------------------------------------------------- /exercises/071-countNumberOfKeys/README.es.md: -------------------------------------------------------------------------------- 1 | # `071` countNumberOfKeys 2 | 3 | ## 📝 Instrucciones: 4 | 5 | 1. Escribe una función llamada `countNumberOfKeys`. Dado un objeto, `countNumberOfKeys` retorna la cantidad de propiedades que el objeto dado tenga. 6 | 7 | ## 📎 Ejemplo: 8 | 9 | ```Javascript 10 | let obj = { 11 | a: 1, 12 | b: 2, 13 | c: 3 14 | }; 15 | let output = countNumberOfKeys(obj); 16 | console.log(output); // --> 3 17 | ``` 18 | -------------------------------------------------------------------------------- /exercises/071-countNumberOfKeys/README.md: -------------------------------------------------------------------------------- 1 | # `071` countNumberOfKeys 2 | 3 | ## 📝 Instructions: 4 | 5 | 1. Write a function called `countNumberOfKeys`. Given an object, `countNumberOfKeys` returns how many properties the given object has. 6 | 7 | ## 📎 Example: 8 | 9 | ```Javascript 10 | let obj = { 11 | a: 1, 12 | b: 2, 13 | c: 3 14 | }; 15 | let output = countNumberOfKeys(obj); 16 | console.log(output); // --> 3 17 | ``` 18 | -------------------------------------------------------------------------------- /exercises/071-countNumberOfKeys/app.js: -------------------------------------------------------------------------------- 1 | let obj = { 2 | firstName: "Rafael", 3 | lastName: "Leao", 4 | country: "Italy", 5 | city: "Milan", 6 | phoneNum: "123-456-789", 7 | jerseyNum: 27 8 | } 9 | 10 | function countNumberOfKeys(obj) { 11 | // your code here 12 | 13 | } 14 | 15 | let output = countNumberOfKeys(obj); 16 | console.log(output); // --> 6 17 | -------------------------------------------------------------------------------- /exercises/071-countNumberOfKeys/solution.hide.js: -------------------------------------------------------------------------------- 1 | let obj = { 2 | firstName: "Rafael", 3 | lastName: "Leao", 4 | country: "Italy", 5 | city: "Milan", 6 | phoneNum: "123-456-789", 7 | jerseyNum: 27 8 | } 9 | 10 | function countNumberOfKeys(obj) { 11 | // your code here 12 | return Object.keys(obj).length; 13 | } 14 | 15 | let output = countNumberOfKeys(obj); 16 | console.log(output); // --> 6 17 | -------------------------------------------------------------------------------- /exercises/072-removeOddValues/README.es.md: -------------------------------------------------------------------------------- 1 | # `072` removeOddValues 2 | 3 | ## 📝 Instrucciones: 4 | 5 | 1. Escribe una función llamada `removeOddValues"`. Dado un objeto, `removeOddValues` elimina cualquier propiedad cuyo valor sea un número impar. 6 | 7 | ## 📎 Ejemplo: 8 | 9 | ```Javascript 10 | let obj = { 11 | a: 2, 12 | b: 3, 13 | c: 4 14 | }; 15 | removeOddValues(obj); 16 | console.log(obj); // --> { a: 2, c: 4 } 17 | ``` 18 | -------------------------------------------------------------------------------- /exercises/072-removeOddValues/README.md: -------------------------------------------------------------------------------- 1 | # `072` removeOddValues 2 | 3 | ## 📝 Instructions: 4 | 5 | 1. Write a function called `removeOddValues`. Given an object, `removeOddValues` removes any properties whose values are odd numbers. 6 | 7 | ## 📎 Example: 8 | 9 | ```Javascript 10 | let obj = { 11 | a: 2, 12 | b: 3, 13 | c: 4 14 | }; 15 | removeOddValues(obj); 16 | console.log(obj); // --> { a: 2, c: 4 } 17 | ``` 18 | -------------------------------------------------------------------------------- /exercises/072-removeOddValues/app.js: -------------------------------------------------------------------------------- 1 | function removeOddValues(obj) { 2 | // your code here 3 | 4 | } 5 | 6 | let obj = { 7 | a: 2, 8 | b: 3, 9 | c: 4 10 | }; 11 | removeOddValues(obj); 12 | console.log(obj); // --> { a: 2, c: 4 } 13 | -------------------------------------------------------------------------------- /exercises/072-removeOddValues/solution.hide.js: -------------------------------------------------------------------------------- 1 | function removeOddValues(obj) { 2 | // your code here 3 | for (let key in obj) { 4 | if (typeof obj[key] === 'number' && obj[key] % 2 !== 0) { 5 | delete obj[key]; 6 | } 7 | } 8 | return obj; 9 | } 10 | 11 | let obj = { 12 | a: 2, 13 | b: 3, 14 | c: 4 15 | }; 16 | removeOddValues(obj); 17 | console.log(obj); // --> { a: 2, c: 4 } 18 | -------------------------------------------------------------------------------- /exercises/073-removeArrayValues/README.es.md: -------------------------------------------------------------------------------- 1 | # `073` removeArrayValues 2 | 3 | ## 📝 Instrucciones: 4 | 5 | 1. Escribe una función llamada `removeArrayValues`. Dado un objeto, `removeArrayValues` elimina cualquier propiedad cuyos valores sean arrays. 6 | 7 | ## 📎 Ejemplo: 8 | 9 | ```Javascript 10 | let obj = { 11 | a: [1, 3, 4], 12 | b: 2, 13 | c: ['hi', 'there'] 14 | } 15 | removeArrayValues(obj); 16 | console.log(obj); // --> { b: 2 } 17 | ``` 18 | -------------------------------------------------------------------------------- /exercises/073-removeArrayValues/README.md: -------------------------------------------------------------------------------- 1 | # `073` removeArrayValues 2 | 3 | ## 📝 Instructions: 4 | 5 | 1. Write a function called `removeArrayValues`. Given an object, `removeArrayValues` removes any properties whose values are arrays. 6 | 7 | ## 📎 Example: 8 | 9 | ```Javascript 10 | let obj = { 11 | a: [1, 3, 4], 12 | b: 2, 13 | c: ['hi', 'there'] 14 | } 15 | removeArrayValues(obj); 16 | console.log(obj); // --> { b: 2 } 17 | ``` 18 | -------------------------------------------------------------------------------- /exercises/073-removeArrayValues/app.js: -------------------------------------------------------------------------------- 1 | function removeArrayValues(obj) { 2 | // your code here 3 | 4 | } -------------------------------------------------------------------------------- /exercises/073-removeArrayValues/solution.hide.js: -------------------------------------------------------------------------------- 1 | function removeArrayValues(obj) { 2 | // your code here 3 | for (let key in obj) { 4 | if (Array.isArray(obj[key])) { 5 | delete obj[key]; 6 | } 7 | } 8 | return obj; 9 | } 10 | -------------------------------------------------------------------------------- /exercises/074-removeNumberValues/README.es.md: -------------------------------------------------------------------------------- 1 | # `074` removeNumberValues 2 | 3 | ## 📝 Instrucciones: 4 | 5 | 1. Escribe una función llamada `removeNumberValues`. Dado un objeto, `removeNumberValues` elimina cualquier propiedad cuyos valores sean números. 6 | 7 | ## 📎 Ejemplo: 8 | 9 | ```Javascript 10 | let obj = { 11 | a: 2, 12 | b: 'remaining', 13 | c: 4 14 | }; 15 | removeNumberValues(obj); 16 | console.log(obj); // --> { b: 'remaining' } 17 | ``` 18 | -------------------------------------------------------------------------------- /exercises/074-removeNumberValues/README.md: -------------------------------------------------------------------------------- 1 | # `074` removeNumberValues 2 | 3 | ## 📝 Instructions: 4 | 5 | 1. Write a function called `removeNumberValues`. Given an object, `removeNumberValues` removes any properties whose values are numbers. 6 | 7 | ## 📎 Example: 8 | 9 | ```Javascript 10 | let obj = { 11 | a: 2, 12 | b: 'remaining', 13 | c: 4 14 | }; 15 | removeNumberValues(obj); 16 | console.log(obj); // --> { b: 'remaining' } 17 | ``` 18 | -------------------------------------------------------------------------------- /exercises/074-removeNumberValues/app.js: -------------------------------------------------------------------------------- 1 | function removeNumberValues(obj) { 2 | // your code here 3 | 4 | } 5 | 6 | let obj = { 7 | a: 2, 8 | b: 'remaining', 9 | c: 4 10 | }; 11 | 12 | removeNumberValues(obj); 13 | console.log(obj); // --> { b: 'remaining' } 14 | -------------------------------------------------------------------------------- /exercises/074-removeNumberValues/solution.hide.js: -------------------------------------------------------------------------------- 1 | function removeNumberValues(obj) { 2 | // your code here 3 | for (let key in obj) { 4 | if (typeof obj[key] === 'number') { 5 | delete obj[key]; 6 | } 7 | } 8 | return obj; 9 | } 10 | 11 | let obj = { 12 | a: 2, 13 | b: 'remaining', 14 | c: 4 15 | }; 16 | 17 | removeNumberValues(obj); 18 | console.log(obj); // --> { b: 'remaining' } 19 | -------------------------------------------------------------------------------- /exercises/075-removeStringValues/README.es.md: -------------------------------------------------------------------------------- 1 | # `075` removeStringValues 2 | 3 | ## 📝 Instrucciones: 4 | 5 | 1. Escribe una función llamada `removeStringValues`. Dado un objeto, `removeStringValues` elimina cualquier propiedad en el objeto cuyo valor sea string. 6 | 7 | ## 📎 Ejemplo: 8 | 9 | ```Javascript 10 | let obj = { 11 | name: 'Sam', 12 | age: 20 13 | } 14 | removeStringValues(obj); 15 | console.log(obj); // --> { age: 20 } 16 | ``` 17 | -------------------------------------------------------------------------------- /exercises/075-removeStringValues/README.md: -------------------------------------------------------------------------------- 1 | # `075` removeStringValues 2 | 3 | ## 📝 Instructions: 4 | 5 | 1. Write a function called `removeStringValues`. Given an object, `removeStringValues` removes any properties whose values are strings. 6 | 7 | ## 📎 Example: 8 | 9 | ```Javascript 10 | let obj = { 11 | name: 'Sam', 12 | age: 20 13 | } 14 | removeStringValues(obj); 15 | console.log(obj); // --> { age: 20 } 16 | ``` 17 | -------------------------------------------------------------------------------- /exercises/075-removeStringValues/app.js: -------------------------------------------------------------------------------- 1 | function removeStringValues(obj) { 2 | // your code here 3 | 4 | } 5 | 6 | let obj = { 7 | name: 'Sam', 8 | age: 20 9 | } 10 | 11 | removeStringValues(obj); 12 | console.log(obj); // --> { age: 20 } 13 | -------------------------------------------------------------------------------- /exercises/075-removeStringValues/solution.hide.js: -------------------------------------------------------------------------------- 1 | function removeStringValues(obj) { 2 | // your code here 3 | for (let key in obj) { 4 | if (typeof obj[key] === 'string') { 5 | delete obj[key]; 6 | } 7 | } 8 | return obj; 9 | } 10 | 11 | let obj = { 12 | name: 'Sam', 13 | age: 20 14 | } 15 | 16 | removeStringValues(obj); 17 | console.log(obj); // --> { age: 20 } 18 | -------------------------------------------------------------------------------- /exercises/076-convertDoubleSpaceToSingle/app.js: -------------------------------------------------------------------------------- 1 | function convertDoubleSpaceToSingle(str) { 2 | // your code here 3 | 4 | } 5 | 6 | let output = convertDoubleSpaceToSingle("string with double spaces"); 7 | console.log(output); // --> "string with double spaces" 8 | -------------------------------------------------------------------------------- /exercises/076-convertDoubleSpaceToSingle/solution.hide.js: -------------------------------------------------------------------------------- 1 | function convertDoubleSpaceToSingle(str) { 2 | // your code here 3 | return str.split(' ').join(' '); 4 | } 5 | 6 | let output = convertDoubleSpaceToSingle("string with double spaces"); 7 | console.log(output); // --> "string with double spaces" 8 | -------------------------------------------------------------------------------- /exercises/077-areValidCredentials/README.es.md: -------------------------------------------------------------------------------- 1 | # `077` areValidCredentials 2 | 3 | ## 📝 Instrucciones: 4 | 5 | 1. Escribe una función llamada `areValidCredentials`. Dado un nombre y una contraseña, `areValidCredentials` retorna `true` si el nombre tiene más de 3 caracteres. 6 | 7 | 2. La contraseña debe tener por lo menos 8 caracteres de lo contrario debe retornar `false`. 8 | 9 | ## 📎 Ejemplo: 10 | 11 | ```js 12 | let output = areValidCredentials('Ritu', 'mylongpassword') 13 | console.log(output); // --> true 14 | ``` 15 | -------------------------------------------------------------------------------- /exercises/077-areValidCredentials/README.md: -------------------------------------------------------------------------------- 1 | # `077` areValidCredentials 2 | 3 | ## 📝 Instructions: 4 | 5 | 1. Write a function called `areValidCredentials`. Given a name and a password, `areValidCredentials`, returns `true` if the name is longer than 3 characters. 6 | 7 | 2. The password must be at least 8 characters long, otherwise it should return `false`. 8 | 9 | ## 📎 Example: 10 | 11 | ```js 12 | let output = areValidCredentials('Ritu', 'mylongpassword') 13 | console.log(output); // --> true 14 | ``` 15 | -------------------------------------------------------------------------------- /exercises/077-areValidCredentials/app.js: -------------------------------------------------------------------------------- 1 | // Write your function here 2 | -------------------------------------------------------------------------------- /exercises/077-areValidCredentials/solution.hide.js: -------------------------------------------------------------------------------- 1 | // Write your function here 2 | function areValidCredentials(name, pass) { 3 | return name.length > 3 && pass.length >= 8; 4 | } 5 | -------------------------------------------------------------------------------- /exercises/078-getIndexOf/app.js: -------------------------------------------------------------------------------- 1 | // Write your function here 2 | -------------------------------------------------------------------------------- /exercises/078-getIndexOf/solution.hide.js: -------------------------------------------------------------------------------- 1 | // Write your function here 2 | function getIndexOf(char, str) { 3 | for(let i = 0; i < str.length; i++) { 4 | if(str[i] == char) { 5 | return i; 6 | } 7 | } 8 | return -1 9 | } 10 | -------------------------------------------------------------------------------- /exercises/079-findMinLengthOfThreeWords/README.es.md: -------------------------------------------------------------------------------- 1 | # `079` findMinLengthOfThreeWords 2 | 3 | ## 📝 Instrucciones: 4 | 5 | 1. Escribe una función llamada `findMinLengthOfThreeWords`. Dadas 3 palabras, `findMinLengthOfThreeWords` retorna la cantidad de letras de la palabra más corta. 6 | 7 | ## 📎 Ejemplo: 8 | 9 | ```js 10 | let output = findMinLengthOfThreeWords('a', 'be', 'see'); 11 | console.log(output); // --> 1 12 | ``` 13 | 14 | ## 💡 Pista: 15 | 16 | + Puedes usar la función `Math.min()` para completar este ejercicio. 17 | -------------------------------------------------------------------------------- /exercises/079-findMinLengthOfThreeWords/README.md: -------------------------------------------------------------------------------- 1 | # `079` findMinLengthOfThreeWords 2 | 3 | ## 📝 Instructions: 4 | 5 | 1. Write a function called `findMinLengthOfThreeWords`. Given 3 words, `findMinLengthOfThreeWords` returns the length of the shortest word. 6 | 7 | ## 📎 Example: 8 | 9 | ```js 10 | let output = findMinLengthOfThreeWords('a', 'be', 'see'); 11 | console.log(output); // --> 1 12 | ``` 13 | 14 | ## 💡 Hint: 15 | 16 | + You can use the function `Math.min()` to complete this exercise. 17 | -------------------------------------------------------------------------------- /exercises/079-findMinLengthOfThreeWords/app.js: -------------------------------------------------------------------------------- 1 | // Write your function here -------------------------------------------------------------------------------- /exercises/079-findMinLengthOfThreeWords/solution.hide.js: -------------------------------------------------------------------------------- 1 | // Write your function here 2 | function findMinLengthOfThreeWords(word1, word2, word3) { 3 | let minLength = Math.min(word1.length, word2.length, word3.length); 4 | return minLength; 5 | } 6 | -------------------------------------------------------------------------------- /exercises/080-findMaxLengthOfThreeWords/README.es.md: -------------------------------------------------------------------------------- 1 | # `080` findMaxLengthOfThreeWords 2 | 3 | ## 📝 Instrucciones: 4 | 5 | 1. Escribe una función llamada `findMaxLengthOfThreeWords`. Dadas 3 palabras, `findMaxLengthOfThreeWords` retorna la cantidad de letras de la palabra más larga. 6 | 7 | ## 📎 Ejemplo: 8 | 9 | ```js 10 | let output = findMaxLengthOfThreeWords('a', 'be', 'see'); 11 | console.log(output); // --> 3 12 | ``` 13 | 14 | ## 💡 Pista: 15 | 16 | + Puedes usar la función `Math.max()` para completar este ejercicio. 17 | -------------------------------------------------------------------------------- /exercises/080-findMaxLengthOfThreeWords/README.md: -------------------------------------------------------------------------------- 1 | # `080` findMaxLengthOfThreeWords 2 | 3 | ## 📝 Instructions: 4 | 5 | 1. Write a function called `findMaxLengthOfThreeWords`. Given 3 words, `findMaxLengthOfThreeWords` returns the length of the longest word. 6 | 7 | ## 📎 Example: 8 | 9 | ```js 10 | let output = findMaxLengthOfThreeWords('a', 'be', 'see'); 11 | console.log(output); // --> 3 12 | ``` 13 | 14 | ## 💡 Hint: 15 | 16 | + You can use the function `Math.max()` to complete this exercise. 17 | -------------------------------------------------------------------------------- /exercises/080-findMaxLengthOfThreeWords/app.js: -------------------------------------------------------------------------------- 1 | // Write your function here -------------------------------------------------------------------------------- /exercises/080-findMaxLengthOfThreeWords/solution.hide.js: -------------------------------------------------------------------------------- 1 | // Write your function here 2 | function findMaxLengthOfThreeWords(word1, word2, word3) { 3 | let maxLength = Math.max(word1.length, word2.length, word3.length); 4 | return maxLength; 5 | } 6 | -------------------------------------------------------------------------------- /exercises/081-repeatString/README.es.md: -------------------------------------------------------------------------------- 1 | # `081` repeatString 2 | 3 | ## 📝 Instrucciones: 4 | 5 | 1. Escribe una función llamada `repeatString`. Dados un string y un número, `repeatString` retorna el string dado tantas veces como el número dado. 6 | 7 | ## 📎 Ejemplo: 8 | 9 | ```Js 10 | let output = repeatString('code', 3); 11 | console.log(output); // --> 'codecodecode' 12 | ``` 13 | 14 | ## 💡 Pista: 15 | 16 | + Hay una manera muy fácil de repetir un string con el método `repeat()`, busca en Internet como usarlo. 17 | -------------------------------------------------------------------------------- /exercises/081-repeatString/README.md: -------------------------------------------------------------------------------- 1 | # `081` repeatString 2 | 3 | ## 📝 Instructions: 4 | 5 | 1. Write a function called `repeatString`. Given a string and a number, `repeatString` returns the given string repeated the given number of times. 6 | 7 | ## 📎 Example: 8 | 9 | ```Js 10 | let output = repeatString('code', 3); 11 | console.log(output); // --> 'codecodecode' 12 | ``` 13 | 14 | ## 💡 Hint: 15 | 16 | + There is a very easy way to repeat a string with the `repeat()` method, search on the Internet how to use it. 17 | -------------------------------------------------------------------------------- /exercises/081-repeatString/app.js: -------------------------------------------------------------------------------- 1 | function repeatString(string, num) { 2 | // your code here 3 | 4 | } 5 | 6 | let output = repeatString('code', 3); 7 | console.log(output); // --> 'codecodecode' 8 | -------------------------------------------------------------------------------- /exercises/081-repeatString/solution.hide.js: -------------------------------------------------------------------------------- 1 | function repeatString(string, num) { 2 | // your code here 3 | return string.repeat(num); 4 | } 5 | 6 | let output = repeatString('code', 3); 7 | console.log(output); // --> 'codecodecode' 8 | -------------------------------------------------------------------------------- /exercises/082-getLongestOfThreeWords/README.es.md: -------------------------------------------------------------------------------- 1 | # `082` getLongestOfThreeWords 2 | 3 | ## 📝 Instrucciones: 4 | 5 | 1. Escribe una función llamada `getLongestOfThreeWords`. Dadas 3 palabras, `getLongestOfThreeWords` retorna la más larga de las tres palabras. 6 | 7 | ## 📎 Ejemplo: 8 | 9 | ```Js 10 | let output = getLongestOfThreeWords('these', 'three', 'words'); 11 | console.log(output); // --> 'these' 12 | ``` 13 | 14 | ## 💡 Pista: 15 | 16 | + Si tienen el mismo largo, debería retornar la primera palabra que encuentre. 17 | -------------------------------------------------------------------------------- /exercises/082-getLongestOfThreeWords/README.md: -------------------------------------------------------------------------------- 1 | # `082` getLongestOfThreeWords 2 | 3 | ## 📝 Instructions: 4 | 5 | 1. Write a function called `getLongestOfThreeWords`. Given 3 words, `getLongestOfThreeWords` returns the longest of three words. 6 | 7 | ## 📎 Example: 8 | 9 | ```Js 10 | let output = getLongestOfThreeWords('these', 'three', 'words'); 11 | console.log(output); // --> 'these' 12 | ``` 13 | 14 | ## 💡 Hint: 15 | 16 | + If there is a tie, it should return the first word in the tie. 17 | -------------------------------------------------------------------------------- /exercises/082-getLongestOfThreeWords/app.js: -------------------------------------------------------------------------------- 1 | function getLongestOfThreeWords(word1, word2, word3) { 2 | // your code here 3 | 4 | } 5 | 6 | let output = getLongestOfThreeWords('these', 'three', 'words'); 7 | console.log(output); // --> 'these' 8 | -------------------------------------------------------------------------------- /exercises/082-getLongestOfThreeWords/solution.hide.js: -------------------------------------------------------------------------------- 1 | function getLongestOfThreeWords(word1, word2, word3) { 2 | // your code here 3 | let aux = ''; 4 | if (word1.length > aux.length) aux = word1; 5 | if (word2.length > aux.length) aux = word2; 6 | if (word3.length > aux.length) aux = word3; 7 | return aux; 8 | } 9 | 10 | let output = getLongestOfThreeWords('these', 'three', 'words'); 11 | console.log(output); // --> 'these' 12 | -------------------------------------------------------------------------------- /exercises/083-findShortestOfThreeWords/README.es.md: -------------------------------------------------------------------------------- 1 | # `083` findShortestOfThreeWords 2 | 3 | ## 📝 Instrucciones: 4 | 5 | 1. Escribe una función llamada `findShortestOfThreeWords`. Dados 3 strings, `findShortestOfThreeWords` regresa el string más corto de los strings dados. 6 | 7 | ## 📎 Ejemplo: 8 | 9 | ```Js 10 | let output = findShortestOfThreeWords('a', 'two', 'three'); 11 | console.log(output); // --> 'a' 12 | ``` 13 | 14 | ## 💡 Pista: 15 | 16 | + Si tienen el mismo largo, debe retornar la primera palabra en la lista de parámetros. 17 | -------------------------------------------------------------------------------- /exercises/083-findShortestOfThreeWords/README.md: -------------------------------------------------------------------------------- 1 | # `083` findShortestOfThreeWords 2 | 3 | ## 📝 Instructions: 4 | 5 | 1. Write a function called `findShortestOfThreeWords`. Given 3 strings, `findShortestOfThreeWords` returns the shortest of the given strings. 6 | 7 | ## 📎 Example: 8 | 9 | ```Js 10 | let output = findShortestOfThreeWords('a', 'two', 'three'); 11 | console.log(output); // --> 'a' 12 | ``` 13 | 14 | ## 💡 Hint: 15 | 16 | + If there is a tie, it should return the first word in the parameters list. 17 | -------------------------------------------------------------------------------- /exercises/083-findShortestOfThreeWords/app.js: -------------------------------------------------------------------------------- 1 | function findShortestOfThreeWords(word1, word2, word3) { 2 | // your code here 3 | 4 | } 5 | 6 | let output = findShortestOfThreeWords('a', 'two', 'three'); 7 | console.log(output); // --> 'a' 8 | -------------------------------------------------------------------------------- /exercises/083-findShortestOfThreeWords/solution.hide.js: -------------------------------------------------------------------------------- 1 | function findShortestOfThreeWords(word1, word2, word3) { 2 | // your code here 3 | let aux = word1; 4 | if (word2.length < aux.length) aux = word2; 5 | if (word3.length < aux.length) aux = word3; 6 | return aux; 7 | } 8 | 9 | let output = findShortestOfThreeWords('a', 'two', 'three'); 10 | console.log(output); // --> 'a' 11 | -------------------------------------------------------------------------------- /exercises/084-joinThreeArrays/README.es.md: -------------------------------------------------------------------------------- 1 | # `084` joinThreeArrays 2 | 3 | ## 📝 Instrucciones: 4 | 5 | 1. Escribe una función llamada `joinThreeArrays`. Dados tres arrays, `joinThreeArrays` retorna un array con los elementos de `arr1` seguido por los elementos del `arr2` y del `arr3` en orden. 6 | 7 | ## 📎 Ejemplo: 8 | 9 | ```Javascript 10 | let output = joinThreeArrays([1, 2], [3, 4], [5, 6]); 11 | console.log(output); // --> [1, 2, 3, 4, 5, 6] 12 | ``` 13 | 14 | ## 💡 Pista: 15 | 16 | + Deberías estar familiarizado con el método `concat()` para este problema. 17 | -------------------------------------------------------------------------------- /exercises/084-joinThreeArrays/README.md: -------------------------------------------------------------------------------- 1 | # `084` joinThreeArrays 2 | 3 | ## 📝 Instructions: 4 | 5 | 1. Write a function called `joinThreeArrays`. Given three arrays, `joinThreeArrays` returns an array with the elements of `arr1` in order followed by the elements in `arr2` followed by the elements of `arr3`. 6 | 7 | ## 📎 Example: 8 | 9 | ```Javascript 10 | let output = joinThreeArrays([1, 2], [3, 4], [5, 6]); 11 | console.log(output); // --> [1, 2, 3, 4, 5, 6] 12 | ``` 13 | 14 | ## 💡 Hint: 15 | 16 | + You should be familiar with the `concat()` method for this problem. 17 | -------------------------------------------------------------------------------- /exercises/084-joinThreeArrays/app.js: -------------------------------------------------------------------------------- 1 | function joinThreeArrays(arr1, arr2, arr3) { 2 | // your code here 3 | 4 | } -------------------------------------------------------------------------------- /exercises/084-joinThreeArrays/solution.hide.js: -------------------------------------------------------------------------------- 1 | function joinThreeArrays(arr1, arr2, arr3) { 2 | // your code here 3 | return arr1.concat(arr2, arr3); 4 | } 5 | -------------------------------------------------------------------------------- /exercises/085-addToFrontOfNew/app.js: -------------------------------------------------------------------------------- 1 | function addToFrontOfNew(arr, element) { 2 | // your code here 3 | 4 | } 5 | 6 | let input = [1, 2]; 7 | let output = addToFrontOfNew(input, 3); 8 | console.log(output); // --> [3, 1, 2]; 9 | console.log(input); // --> [1, 2] 10 | -------------------------------------------------------------------------------- /exercises/085-addToFrontOfNew/solution.hide.js: -------------------------------------------------------------------------------- 1 | function addToFrontOfNew(arr, element) { 2 | // your code here 3 | let newArr = [element, ...arr]; 4 | return newArr; 5 | } 6 | 7 | let input = [1, 2]; 8 | let output = addToFrontOfNew(input, 3); 9 | console.log(output); // --> [3, 1, 2]; 10 | console.log(input); // --> [1, 2] 11 | -------------------------------------------------------------------------------- /exercises/086-addToBackOfNew/README.es.md: -------------------------------------------------------------------------------- 1 | # `086` addToBackOfNew 2 | 3 | ## 📝 Instrucciones: 4 | 5 | 1. Escribe una función llamada `addToBackOfNew`. Dado un array y un elemento, `addToBackOfNew` retorna un clon de ese array dado con el elemento añadido al final. 6 | 7 | ## 📎 Ejemplo: 8 | 9 | ```js 10 | let input = [1, 2]; 11 | let output = addToBackOfNew(input, 3); 12 | console.log(input); // --> [1, 2] 13 | console.log(output); // --> [1, 2, 3] 14 | ``` 15 | 16 | ## 💡 Pista: 17 | 18 | + Debe crear un NUEVO array y no modificar el array original. 19 | -------------------------------------------------------------------------------- /exercises/086-addToBackOfNew/README.md: -------------------------------------------------------------------------------- 1 | # `086` addToBackOfNew 2 | 3 | ## 📝 Instructions: 4 | 5 | 1. Write a function called `addToBackOfNew`. Given an array and an element, `addToBackOfNew` returns a clone of the given array, with the given element added to the end. 6 | 7 | ## 📎 Example: 8 | 9 | ```js 10 | let input = [1, 2]; 11 | let output = addToBackOfNew(input, 3); 12 | console.log(input); // --> [1, 2] 13 | console.log(output); // --> [1, 2, 3] 14 | ``` 15 | 16 | ## 💡 Hint: 17 | 18 | + It should return a NEW array, instead of modifying the original one. 19 | -------------------------------------------------------------------------------- /exercises/086-addToBackOfNew/app.js: -------------------------------------------------------------------------------- 1 | function addToBackOfNew(arr, element) { 2 | // your code here 3 | 4 | } 5 | 6 | let input = [1, 2]; 7 | let output = addToBackOfNew(input, 3); 8 | console.log(input); // --> [1, 2] 9 | console.log(output); // --> [1, 2, 3] 10 | -------------------------------------------------------------------------------- /exercises/086-addToBackOfNew/solution.hide.js: -------------------------------------------------------------------------------- 1 | function addToBackOfNew(arr, element) { 2 | // your code here 3 | let newArr = [] 4 | arr.forEach(e=>{ 5 | newArr.push(e) 6 | }) 7 | 8 | newArr.push(element) 9 | return newArr 10 | } 11 | 12 | let input = [1, 2]; 13 | let output = addToBackOfNew(input, 3); 14 | console.log(input); // --> [1, 2] 15 | console.log(output); // --> [1, 2, 3] 16 | -------------------------------------------------------------------------------- /exercises/087-getAllElementsButNth/README.es.md: -------------------------------------------------------------------------------- 1 | # `087` getAllElementsButNth 2 | 3 | ## 📝 Instrucciones: 4 | 5 | 1. Escribe una función llamada `getAllElementsButNth`. Dado un array y un índice, `getAllElementsButNth` retorna un array con todos los elementos salvo el *Nth*. 6 | 7 | ## 📎 Ejemplo: 8 | 9 | ```js 10 | let output = getAllElementsButNth(['a', 'b', 'c'], 1); 11 | console.log(output); // --> ['a', 'c'] 12 | ``` 13 | 14 | ## 💡 Pista: 15 | 16 | + Una forma de hacer este ejercicio es con el método `splice()`, deberías investigarlo. 17 | -------------------------------------------------------------------------------- /exercises/087-getAllElementsButNth/README.md: -------------------------------------------------------------------------------- 1 | # `087` getAllElementsButNth 2 | 3 | ## 📝 Instructions: 4 | 5 | 1. Write a function called `getAllElementsButNth`. Given an array and an index, `getAllElementsButNth` returns an array with all the elements but the *Nth*. 6 | 7 | ## 📎 Example: 8 | 9 | ```js 10 | let output = getAllElementsButNth(['a', 'b', 'c'], 1); 11 | console.log(output); // --> ['a', 'c'] 12 | ``` 13 | 14 | ## 💡 Hint: 15 | 16 | + One way to do this exercise is with the method `splice()`, you should search about it. 17 | -------------------------------------------------------------------------------- /exercises/087-getAllElementsButNth/app.js: -------------------------------------------------------------------------------- 1 | function getAllElementsButNth(array, n) { 2 | // your code here 3 | 4 | } 5 | 6 | let output = getAllElementsButNth(['a', 'b', 'c'], 1); 7 | console.log(output); // --> ['a', 'c'] 8 | -------------------------------------------------------------------------------- /exercises/087-getAllElementsButNth/solution.hide.js: -------------------------------------------------------------------------------- 1 | function getAllElementsButNth(array, n) { 2 | // your code here 3 | array.splice(n, 1); 4 | return array 5 | } 6 | 7 | let output = getAllElementsButNth(['a', 'b', 'c'], 1); 8 | console.log(output); // --> ['a', 'c'] 9 | -------------------------------------------------------------------------------- /exercises/088-keep/app.js: -------------------------------------------------------------------------------- 1 | // Write your function here 2 | -------------------------------------------------------------------------------- /exercises/088-keep/solution.hide.js: -------------------------------------------------------------------------------- 1 | // Write your function here 2 | function keep(arr, keeper) { 3 | return arr.filter((element) => element === keeper); 4 | } 5 | -------------------------------------------------------------------------------- /exercises/089-removeElement/app.js: -------------------------------------------------------------------------------- 1 | // Write your function here 2 | -------------------------------------------------------------------------------- /exercises/089-removeElement/solution.hide.js: -------------------------------------------------------------------------------- 1 | // Write your function here 2 | function removeElement(arr, n) { 3 | return arr.filter((element) => element !== n); 4 | } 5 | -------------------------------------------------------------------------------- /exercises/090-filterOddLengthWords/app.js: -------------------------------------------------------------------------------- 1 | function filterOddLengthWords(words) { 2 | // your code here 3 | 4 | } 5 | 6 | let output = filterOddLengthWords(['there', 'it', 'is', 'now']); 7 | console.log(output); // --> ['there', 'now'] 8 | -------------------------------------------------------------------------------- /exercises/090-filterOddLengthWords/solution.hide.js: -------------------------------------------------------------------------------- 1 | function filterOddLengthWords(words) { 2 | // your code here 3 | return words.filter((item) => item.length % 2 !== 0) 4 | } 5 | 6 | let output = filterOddLengthWords(['there', 'it', 'is', 'now']); 7 | console.log(output); // --> ['there', 'now'] 8 | -------------------------------------------------------------------------------- /exercises/091-filterEvenLengthWords/README.es.md: -------------------------------------------------------------------------------- 1 | # `091` filterEvenLengthWords 2 | 3 | ## 📝 Instrucciones: 4 | 5 | 1. Escribe una función llamada `filterEvenLengthWords`. Dado un array de strings, `filterEvenLengthWords` retorna un array que contenga solo los elementos del array cuya longitud es un número par. 6 | 7 | ## 📎 Ejemplo: 8 | 9 | ```Js 10 | let output = filterEvenLengthWords(['word', 'horse', 'car', 'computer']); 11 | console.log(output); // --> ['word', 'computer'] 12 | ``` 13 | -------------------------------------------------------------------------------- /exercises/091-filterEvenLengthWords/README.md: -------------------------------------------------------------------------------- 1 | # `091` filterEvenLengthWords 2 | 3 | ## 📝 Instructions: 4 | 5 | 1. Write a function called `filterEvenLengthWords`. Given an array of strings, `filterEvenLengthWords` returns an array containing only the elements of the given array whose length is an even number. 6 | 7 | ## 📎 Example: 8 | 9 | ```Js 10 | let output = filterEvenLengthWords(['word', 'horse', 'car', 'computer']); 11 | console.log(output); // --> ['word', 'computer'] 12 | ``` 13 | -------------------------------------------------------------------------------- /exercises/091-filterEvenLengthWords/app.js: -------------------------------------------------------------------------------- 1 | function filterEvenLengthWords(words) { 2 | // your code here 3 | 4 | } 5 | 6 | let output = filterEvenLengthWords(['word', 'words', 'word', 'words']); 7 | console.log(output); // --> ['word', 'word'] 8 | -------------------------------------------------------------------------------- /exercises/091-filterEvenLengthWords/solution.hide.js: -------------------------------------------------------------------------------- 1 | function filterEvenLengthWords(words) { 2 | // your code here 3 | return words.filter(item => item.length % 2 === 0); 4 | } 5 | 6 | let output = filterEvenLengthWords(['word', 'words', 'word', 'words']); 7 | console.log(output); // --> ['word', 'word'] 8 | -------------------------------------------------------------------------------- /exercises/092-getFirstElementOfProperty/app.js: -------------------------------------------------------------------------------- 1 | // Write your function here 2 | -------------------------------------------------------------------------------- /exercises/092-getFirstElementOfProperty/solution.hide.js: -------------------------------------------------------------------------------- 1 | // Write your function here 2 | function getFirstElementOfProperty(obj, key) { 3 | if(!obj[key] || !Array.isArray(obj[key])) { 4 | return undefined 5 | } 6 | 7 | return obj[key][0] 8 | } 9 | -------------------------------------------------------------------------------- /exercises/093-getNthElementOfProperty/app.js: -------------------------------------------------------------------------------- 1 | // Write your function here 2 | -------------------------------------------------------------------------------- /exercises/093-getNthElementOfProperty/solution.hide.js: -------------------------------------------------------------------------------- 1 | // Write your function here 2 | function getNthElementOfProperty(obj, key, n) { 3 | if(!obj[key] || !Array.isArray(obj[key]) || n >= obj[key].length) { 4 | return undefined 5 | } 6 | return obj[key][n]; 7 | } 8 | -------------------------------------------------------------------------------- /exercises/094-getLastElementOfProperty/app.js: -------------------------------------------------------------------------------- 1 | // Write your function here 2 | -------------------------------------------------------------------------------- /exercises/094-getLastElementOfProperty/solution.hide.js: -------------------------------------------------------------------------------- 1 | // Write your function here 2 | function getLastElementOfProperty(obj, key) { 3 | if(!obj[key] || !Array.isArray(obj[key])) { 4 | return undefined; 5 | } 6 | 7 | return obj[key][obj[key].length - 1] 8 | } 9 | -------------------------------------------------------------------------------- /exercises/095-getElementsThatEqual10AtProperty/app.js: -------------------------------------------------------------------------------- 1 | // Write your function here 2 | -------------------------------------------------------------------------------- /exercises/095-getElementsThatEqual10AtProperty/solution.hide.js: -------------------------------------------------------------------------------- 1 | // Write your function here 2 | function getElementsThatEqual10AtProperty(obj, key) { 3 | if(!obj[key] || obj[key].length == 0 || !Array.isArray(obj[key])) { 4 | return [] 5 | } 6 | 7 | let arr = obj[key] 8 | let newArr = [] 9 | 10 | arr.forEach(e => { 11 | if(e === 10) { 12 | newArr.push(e) 13 | } 14 | }) 15 | return newArr; 16 | } 17 | -------------------------------------------------------------------------------- /exercises/096-getElementsLessThanOneHundredAtProperty/app.js: -------------------------------------------------------------------------------- 1 | // Write your function here 2 | -------------------------------------------------------------------------------- /exercises/096-getElementsLessThanOneHundredAtProperty/solution.hide.js: -------------------------------------------------------------------------------- 1 | // Write your function here 2 | function getElementsLessThan100AtProperty(obj, key) { 3 | if(!obj[key] || obj[key].length == 0 || !Array.isArray(obj[key])) { 4 | return [] 5 | } 6 | 7 | let arr = obj[key] 8 | let newArr = [] 9 | 10 | arr.forEach(e => { 11 | if(e < 100) { 12 | newArr.push(e) 13 | } 14 | }) 15 | return newArr; 16 | } 17 | -------------------------------------------------------------------------------- /exercises/097-getElementsGreaterThanTenAtProperty/app.js: -------------------------------------------------------------------------------- 1 | // Write your function here 2 | -------------------------------------------------------------------------------- /exercises/097-getElementsGreaterThanTenAtProperty/solution.hide.js: -------------------------------------------------------------------------------- 1 | // Write your function here 2 | function getElementsGreaterThan10AtProperty(obj, key) { 3 | if(!obj[key] || obj[key].length == 0 || !Array.isArray(obj[key])) { 4 | return [] 5 | } 6 | 7 | let arr = obj[key] 8 | let newArr = [] 9 | 10 | arr.forEach(e => { 11 | if (e > 10) { 12 | newArr.push(e) 13 | } 14 | }) 15 | return newArr; 16 | } 17 | -------------------------------------------------------------------------------- /exercises/098-getOddLengthWordsAtProperty/app.js: -------------------------------------------------------------------------------- 1 | // Write your function here 2 | -------------------------------------------------------------------------------- /exercises/098-getOddLengthWordsAtProperty/solution.hide.js: -------------------------------------------------------------------------------- 1 | // Write your function here 2 | function getOddLengthWordsAtProperty(obj, key) { 3 | if(!obj[key] || !Array.isArray(obj[key]) || obj[key].length == 0) { 4 | return [] 5 | } 6 | 7 | let newArr = []; 8 | for(let i = 0; i < obj[key].length; i++) { 9 | if(obj[key][i].length % 2 !== 0) { 10 | newArr.push(obj[key][i]) 11 | } 12 | } 13 | return newArr; 14 | } 15 | -------------------------------------------------------------------------------- /exercises/099-getAverageOfElementsAtProperty/app.js: -------------------------------------------------------------------------------- 1 | function getAverageOfElementsAtProperty(obj, key) { 2 | // your code here 3 | 4 | } -------------------------------------------------------------------------------- /exercises/099-getAverageOfElementsAtProperty/solution.hide.js: -------------------------------------------------------------------------------- 1 | function getAverageOfElementsAtProperty(obj, key) { 2 | // your code here 3 | if(!obj[key] || !Array.isArray(obj[key]) || obj[key].length == 0) { 4 | return 0; 5 | } 6 | 7 | let sum = 0; 8 | 9 | for (let i = 0; i < obj[key].length; i++) { 10 | sum+=obj[key][i] 11 | } 12 | 13 | return sum / obj[key].length; 14 | } 15 | -------------------------------------------------------------------------------- /exercises/100-getEvenLengthWordsAtProperty/app.js: -------------------------------------------------------------------------------- 1 | function getEvenLengthWordsAtProperty(obj, key) { 2 | // your code here 3 | 4 | } 5 | 6 | let obj = { 7 | key: ['a', 'long', 'game'] 8 | }; 9 | let output = getEvenLengthWordsAtProperty(obj, 'key'); 10 | console.log(output); // --> ['long', 'game'] 11 | -------------------------------------------------------------------------------- /exercises/100-getEvenLengthWordsAtProperty/solution.hide.js: -------------------------------------------------------------------------------- 1 | function getEvenLengthWordsAtProperty(obj, key) { 2 | // your code here 3 | if (!Array.isArray(obj[key])) { 4 | return []; 5 | } 6 | 7 | return obj[key].filter(word => word.length % 2 === 0); 8 | } 9 | 10 | let obj = { 11 | key: ['a', 'long', 'game'] 12 | }; 13 | let output = getEvenLengthWordsAtProperty(obj, 'key'); 14 | console.log(output); // --> ['long', 'game'] 15 | -------------------------------------------------------------------------------- /exercises/101-getOddElementsAtProperty/app.js: -------------------------------------------------------------------------------- 1 | function getOddElementsAtProperty(obj, key) { 2 | // your code here 3 | 4 | } 5 | 6 | let obj = { 7 | key: [1, 2, 3, 4, 5] 8 | }; 9 | let output = getOddElementsAtProperty(obj, 'key'); 10 | console.log(output); // --> [1, 3, 5] 11 | -------------------------------------------------------------------------------- /exercises/101-getOddElementsAtProperty/solution.hide.js: -------------------------------------------------------------------------------- 1 | function getOddElementsAtProperty(obj, key) { 2 | // your code here 3 | if (!obj.hasOwnProperty(key) || !Array.isArray(obj[key])) { 4 | return []; 5 | } 6 | 7 | return obj[key].filter(num => num % 2 !== 0); 8 | } 9 | 10 | let obj = { 11 | key: [1, 2, 3, 4, 5] 12 | }; 13 | let output = getOddElementsAtProperty(obj, 'key'); 14 | console.log(output); // --> [1, 3, 5] 15 | -------------------------------------------------------------------------------- /exercises/102-getEvenElementsAtProperty/app.js: -------------------------------------------------------------------------------- 1 | function getEvenElementsAtProperty(obj, key) { 2 | // your code here 3 | 4 | } 5 | 6 | let obj = { 7 | key: [1000, 11, 50, 17] 8 | }; 9 | let output = getEvenElementsAtProperty(obj, 'key'); 10 | console.log(output); // --> [1000, 50] 11 | -------------------------------------------------------------------------------- /exercises/102-getEvenElementsAtProperty/solution.hide.js: -------------------------------------------------------------------------------- 1 | function getEvenElementsAtProperty(obj, key) { 2 | // your code here 3 | if (!Array.isArray(obj[key])) { 4 | return []; 5 | } 6 | 7 | return obj[key].filter(element => element % 2 === 0); 8 | } 9 | 10 | let obj = { 11 | key: [1000, 11, 50, 17] 12 | }; 13 | let output = getEvenElementsAtProperty(obj, 'key'); 14 | console.log(output); // --> [1000, 50] 15 | -------------------------------------------------------------------------------- /exercises/103-getSquaredElementsAtProperty/app.js: -------------------------------------------------------------------------------- 1 | function getSquaredElementsAtProperty(obj, key) { 2 | // your code here 3 | 4 | } 5 | 6 | let obj = { 7 | key: [2, 1, 5] 8 | }; 9 | let output = getSquaredElementsAtProperty(obj, 'key'); 10 | console.log(output); // --> [4, 1, 25] 11 | -------------------------------------------------------------------------------- /exercises/103-getSquaredElementsAtProperty/solution.hide.js: -------------------------------------------------------------------------------- 1 | function getSquaredElementsAtProperty(obj, key) { 2 | // Your code here 3 | if (!obj[key] || !Array.isArray(obj[key]) || obj[key].length < 1) { 4 | return [] 5 | } 6 | 7 | return obj[key].map(e => e * e); 8 | } 9 | 10 | let obj = { 11 | key: [2, 1, 5] 12 | }; 13 | let output = getSquaredElementsAtProperty(obj, 'key'); 14 | console.log(output); // --> [4, 1, 25] 15 | -------------------------------------------------------------------------------- /exercises/104-getSmallestElementAtProperty/app.js: -------------------------------------------------------------------------------- 1 | function getSmallestElementAtProperty(obj, key) { 2 | // your code here 3 | 4 | } 5 | 6 | let obj = { 7 | key: [2, 1, 5] 8 | }; 9 | let output = getSmallestElementAtProperty(obj, 'key'); 10 | console.log(output); // --> 1 11 | -------------------------------------------------------------------------------- /exercises/105-getLargestElementAtProperty/app.js: -------------------------------------------------------------------------------- 1 | function getLargestElementAtProperty(obj, key) { 2 | // your code here 3 | 4 | } 5 | 6 | let obj = { 7 | key: [1, 2, 4] 8 | }; 9 | let output = getLargestElementAtProperty(obj, 'key'); 10 | console.log(output); // --> 4 11 | -------------------------------------------------------------------------------- /exercises/106-getAllButLastElementOfProperty/app.js: -------------------------------------------------------------------------------- 1 | function getAllButLastElementOfProperty(obj, key) { 2 | // your code here 3 | 4 | } 5 | 6 | let obj = { 7 | key: [1, 2, 3] 8 | }; 9 | let output = getAllButLastElementOfProperty(obj, 'key'); 10 | console.log(output); // --> [1, 2] 11 | -------------------------------------------------------------------------------- /exercises/106-getAllButLastElementOfProperty/solution.hide.js: -------------------------------------------------------------------------------- 1 | function getAllButLastElementOfProperty(obj, key) { 2 | // your code here 3 | if (!obj[key] || !Array.isArray(obj[key]) || obj[key].length < 1) return [] 4 | else { 5 | return obj[key].slice(0, -1); 6 | } 7 | } 8 | 9 | let obj = { 10 | key: [1, 2, 3] 11 | }; 12 | let output = getAllButLastElementOfProperty(obj, 'key'); 13 | console.log(output); // --> [1, 2] 14 | -------------------------------------------------------------------------------- /exercises/107-getElementOfArrayProperty/app.js: -------------------------------------------------------------------------------- 1 | function getElementOfArrayProperty(obj, key, index) { 2 | // your code here 3 | 4 | } 5 | 6 | let obj = { 7 | key: ['Jamil', 'Albrey'] 8 | }; 9 | let output = getElementOfArrayProperty(obj, 'key', 0); 10 | console.log(output); // --> 'Jamil' 11 | -------------------------------------------------------------------------------- /exercises/107-getElementOfArrayProperty/solution.hide.js: -------------------------------------------------------------------------------- 1 | function getElementOfArrayProperty(obj, key, index) { 2 | // your code here 3 | if (!obj[key]) return undefined; 4 | if (obj[key][index]) return obj[key][index]; 5 | else return undefined; 6 | } 7 | 8 | let obj = { 9 | key: ['Jamil', 'Albrey'] 10 | }; 11 | let output = getElementOfArrayProperty(obj, 'key', 0); 12 | console.log(output); // --> 'Jamil' 13 | -------------------------------------------------------------------------------- /exercises/108-getProductOfAllElementsAtProperty/app.js: -------------------------------------------------------------------------------- 1 | function getProductOfAllElementsAtProperty(obj, key) { 2 | // your code here 3 | 4 | } 5 | 6 | let obj = { 7 | key: [1, 2, 3, 4] 8 | }; 9 | let output = getProductOfAllElementsAtProperty(obj, 'key'); 10 | console.log(output); // --> 24 11 | -------------------------------------------------------------------------------- /exercises/108-getProductOfAllElementsAtProperty/solution.hide.js: -------------------------------------------------------------------------------- 1 | function getProductOfAllElementsAtProperty(obj, key) { 2 | // your code here 3 | if (!obj[key] || !Array.isArray(obj[key]) || obj[key].length < 1) return 0; 4 | 5 | let aux = 1; 6 | for (let e of obj[key]) { 7 | aux *= e; 8 | } 9 | 10 | return aux; 11 | } 12 | 13 | let obj = { 14 | key: [1, 2, 3, 4], 15 | }; 16 | let output = getProductOfAllElementsAtProperty(obj, 'key'); 17 | console.log(output); // --> 24 18 | -------------------------------------------------------------------------------- /exercises/109-Select/app.js: -------------------------------------------------------------------------------- 1 | // Write your function here 2 | -------------------------------------------------------------------------------- /exercises/109-Select/solution.hide.js: -------------------------------------------------------------------------------- 1 | // Write your function here 2 | function select(arr, obj) { 3 | let newObj = {}; 4 | arr.forEach((e) => { 5 | if(obj[e]) { 6 | newObj[e] = obj[e] 7 | } 8 | }) 9 | return newObj 10 | } 11 | -------------------------------------------------------------------------------- /exercises/110-getSumOfAllElementsAtProperty/app.js: -------------------------------------------------------------------------------- 1 | function getSumOfAllElementsAtProperty(obj, key) { 2 | // your code here 3 | 4 | } 5 | 6 | let obj = { 7 | key: [4, 1, 8] 8 | }; 9 | let output = getSumOfAllElementsAtProperty(obj, 'key'); 10 | console.log(output); // --> 13 11 | -------------------------------------------------------------------------------- /exercises/110-getSumOfAllElementsAtProperty/solution.hide.js: -------------------------------------------------------------------------------- 1 | function getSumOfAllElementsAtProperty(obj, key) { 2 | // your code here 3 | let aux = 0; 4 | 5 | if (obj.hasOwnProperty(key) && obj[key].length > 0) { 6 | for (let e of obj[key]) { 7 | aux += e; 8 | } 9 | } else { 10 | return 0; 11 | } 12 | 13 | return aux; 14 | } 15 | 16 | let obj = { 17 | key: [4, 1, 8], 18 | }; 19 | let output = getSumOfAllElementsAtProperty(obj, 'key'); 20 | console.log(output); // --> 13 21 | -------------------------------------------------------------------------------- /exercises/111-countAllCharacters/app.js: -------------------------------------------------------------------------------- 1 | // Write your function here 2 | -------------------------------------------------------------------------------- /exercises/111-countAllCharacters/solution.hide.js: -------------------------------------------------------------------------------- 1 | // Write your function here 2 | function countAllCharacters(str) { 3 | if(str.length == 0) { 4 | return {} 5 | } 6 | 7 | let obj = {} 8 | 9 | for(let i = 0; i < str.length; i++) { 10 | if(obj[str[i]]) { 11 | obj[str[i]] = obj[str[i]] + 1 12 | } else { 13 | obj[str[i]] = 1 14 | } 15 | } 16 | return obj; 17 | } 18 | -------------------------------------------------------------------------------- /exercises/112-getLengthOfLongestElement/README.es.md: -------------------------------------------------------------------------------- 1 | # `112` getLengthOfLongestElement 2 | 3 | ## 📝 Instrucciones: 4 | 5 | 1. Escribe una función llamada `getLengthOfLongestElement`. Dado un array, `getLengthOfLongestElement` retorna la longitud del string más largo en el array. 6 | 7 | ## 📎 Ejemplo: 8 | 9 | ```Js 10 | let output = getLengthOfLongestElement(['one', 'two', 'three']); 11 | console.log(output); // --> 5 12 | ``` 13 | 14 | ## 💡 Pista: 15 | 16 | + Si el array está vacío, debe retornar `0`. 17 | -------------------------------------------------------------------------------- /exercises/112-getLengthOfLongestElement/README.md: -------------------------------------------------------------------------------- 1 | # `112` getLengthOfLongestElement 2 | 3 | ## 📝 Instructions: 4 | 5 | 1. Write a function called `getLengthOfLongestElement`. Given an array, `getLengthOfLongestElement` returns the length of the longest string in the given array. 6 | 7 | ## 📎 Example: 8 | 9 | ```Js 10 | let output = getLengthOfLongestElement(['one', 'two', 'three']); 11 | console.log(output); // --> 5 12 | ``` 13 | 14 | ## 💡 Hint: 15 | 16 | + If the array is empty, it should return `0`. 17 | -------------------------------------------------------------------------------- /exercises/112-getLengthOfLongestElement/app.js: -------------------------------------------------------------------------------- 1 | function getLengthOfLongestElement(arr) { 2 | // Your code here 3 | 4 | } 5 | 6 | let output = getLengthOfLongestElement(['one', 'two', 'three']); 7 | console.log(output); // --> 5 8 | -------------------------------------------------------------------------------- /exercises/112-getLengthOfLongestElement/solution.hide.js: -------------------------------------------------------------------------------- 1 | function getLengthOfLongestElement(arr) { 2 | // your code here 3 | let longestLength = 0; 4 | for (let i = 0; i < arr.length; i++) { 5 | if (arr[i].length > longestLength) { 6 | longestLength = arr[i].length; 7 | } 8 | } 9 | 10 | return longestLength; 11 | } 12 | 13 | let output = getLengthOfLongestElement(['one', 'two', 'three']); 14 | console.log(output); // --> 5 15 | -------------------------------------------------------------------------------- /exercises/113-squareElements/README.es.md: -------------------------------------------------------------------------------- 1 | # `113` squareElements 2 | 3 | ## 📝 Instrucciones: 4 | 5 | 1. Escribe una función llamada `squareElements`. Dado un array de números, `squareElements` deberá retornar un nuevo array donde cada elemento es el cuadrado de cada elemento del array dado. 6 | 7 | ## 📎 Ejemplo: 8 | 9 | ```Js 10 | let output = squareElements([1, 2, 3]); 11 | console.log(output); // --> [1, 4, 9] 12 | ``` 13 | -------------------------------------------------------------------------------- /exercises/113-squareElements/README.md: -------------------------------------------------------------------------------- 1 | # `113` squareElements 2 | 3 | ## 📝 Instructions: 4 | 5 | 1. Write a function called `squareElements`. Given an array of numbers, `squareElements` should return a new array where each element is the square of the element of the given array. 6 | 7 | ## 📎 Example: 8 | 9 | ```Js 10 | let output = squareElements([1, 2, 3]); 11 | console.log(output); // --> [1, 4, 9] 12 | ``` 13 | -------------------------------------------------------------------------------- /exercises/113-squareElements/app.js: -------------------------------------------------------------------------------- 1 | function squareElements(arr) { 2 | // your code here 3 | 4 | } 5 | 6 | let output = squareElements([1, 2, 3]); 7 | console.log(output); // --> [1, 4, 9] 8 | -------------------------------------------------------------------------------- /exercises/113-squareElements/solution.hide.js: -------------------------------------------------------------------------------- 1 | function squareElements(arr) { 2 | // your code here 3 | return arr.map(num => num ** 2); 4 | } 5 | 6 | let output = squareElements([1, 2, 3]); 7 | console.log(output); // --> [1, 4, 9] 8 | -------------------------------------------------------------------------------- /exercises/114-filterOddElements/README.es.md: -------------------------------------------------------------------------------- 1 | # `114` filterOddElements 2 | 3 | ## 📝 Instrucciones: 4 | 5 | 1. Escribe una función llamada `filterOddElements`. Dado un array de números, `filterOddElements` devuelve un array que contiene solo los números impares del array dado. 6 | 7 | ## 📎 Ejemplo: 8 | 9 | ```Js 10 | let output = filterOddElements([1, 2, 3, 4, 5]); 11 | console.log(output); // --> [1, 3, 5] 12 | ``` 13 | -------------------------------------------------------------------------------- /exercises/114-filterOddElements/README.md: -------------------------------------------------------------------------------- 1 | # `114` filterOddElements 2 | 3 | ## 📝 Instructions: 4 | 5 | 1. Write a function called `filterOddElements`. Given an array of numbers, `filterOddElements` returns an array containing only the odd numbers of the given array. 6 | 7 | ## 📎 Example: 8 | 9 | ```Js 10 | let output = filterOddElements([1, 2, 3, 4, 5]); 11 | console.log(output); // --> [1, 3, 5] 12 | ``` 13 | -------------------------------------------------------------------------------- /exercises/114-filterOddElements/app.js: -------------------------------------------------------------------------------- 1 | function filterOddElements(arr) { 2 | // your code here 3 | 4 | } 5 | 6 | let output = filterOddElements([1, 2, 3, 4, 5]); 7 | console.log(output); // --> [1, 3, 5] 8 | -------------------------------------------------------------------------------- /exercises/114-filterOddElements/solution.hide.js: -------------------------------------------------------------------------------- 1 | function filterOddElements(arr) { 2 | // your code here 3 | return arr.filter(num => num % 2 !== 0); 4 | } 5 | 6 | let output = filterOddElements([1, 2, 3, 4, 5]); 7 | console.log(output); // --> [1, 3, 5] 8 | -------------------------------------------------------------------------------- /exercises/115-computeProductOfAllElements/README.es.md: -------------------------------------------------------------------------------- 1 | # `115` computeProductOfAllElements 2 | 3 | ## 📝 Instrucciones: 4 | 5 | 1. Escribe una función llamada `computeProductOfAllElements`. Dado un array de números, `computeProductOfAllElements` devuelve los productos de todos los elementos del array dado. 6 | 7 | ## 📎 Ejemplo: 8 | 9 | ```Js 10 | let output = computeProductOfAllElements([2, 5, 6]); 11 | console.log(output); // --> 60 12 | ``` 13 | 14 | ## 💡 Pista: 15 | 16 | + Si el array dado está vacío, debería devolver `0`. 17 | -------------------------------------------------------------------------------- /exercises/115-computeProductOfAllElements/README.md: -------------------------------------------------------------------------------- 1 | # `115` computeProductOfAllElements 2 | 3 | ## 📝 Instructions: 4 | 5 | 1. Write a function called `computeProductOfAllElements`. Given an array of numbers, `computeProductOfAllElements` returns the products of all the elements in the given array. 6 | 7 | ## 📎 Example: 8 | 9 | ```Js 10 | let output = computeProductOfAllElements([2, 5, 6]); 11 | console.log(output); // --> 60 12 | ``` 13 | 14 | ## 💡 Hint: 15 | 16 | + If the given array is empty, it should return `0`. 17 | -------------------------------------------------------------------------------- /exercises/115-computeProductOfAllElements/app.js: -------------------------------------------------------------------------------- 1 | function computeProductOfAllElements(arr) { 2 | // your code here 3 | 4 | } 5 | 6 | let output = computeProductOfAllElements([2, 5, 6]); 7 | console.log(output); // --> 60 8 | -------------------------------------------------------------------------------- /exercises/115-computeProductOfAllElements/solution.hide.js: -------------------------------------------------------------------------------- 1 | function computeProductOfAllElements(arr) { 2 | // your code here 3 | let result = 1; 4 | if (arr.length < 1) return 0; 5 | for (let e of arr) { 6 | result *= e; 7 | } 8 | return result; 9 | } 10 | 11 | let output = computeProductOfAllElements([2, 5, 6]); 12 | console.log(output); // --> 60 13 | -------------------------------------------------------------------------------- /exercises/116-filterEvenElements/README.es.md: -------------------------------------------------------------------------------- 1 | # `116` filterEvenElements 2 | 3 | ## 📝 Instrucciones: 4 | 5 | 1. Escribe una función llamada `filterEvenElements`. Dado un array de números, `filterEvenElements` retorna un array que contenga solo los números pares encontrados en el array. 6 | 7 | ## 📎 Ejemplo: 8 | 9 | ```Js 10 | let output = filterEvenElements([2, 3, 4, 5, 6]); 11 | console.log(output); // --> [2, 4, 6] 12 | ``` 13 | -------------------------------------------------------------------------------- /exercises/116-filterEvenElements/README.md: -------------------------------------------------------------------------------- 1 | # `116` filterEvenElements 2 | 3 | ## 📝 Instructions: 4 | 5 | 1. Write a function called `filterEvenElements`. Given an array of numbers, `filterEvenElements` returns an array containing only the even numbers of the given array. 6 | 7 | ## 📎 Example: 8 | 9 | ```Js 10 | let output = filterEvenElements([2, 3, 4, 5, 6]); 11 | console.log(output); // --> [2, 4, 6] 12 | ``` 13 | -------------------------------------------------------------------------------- /exercises/116-filterEvenElements/app.js: -------------------------------------------------------------------------------- 1 | function filterEvenElements(arr) { 2 | // your code here 3 | 4 | } 5 | 6 | let output = filterEvenElements([2, 3, 4, 5, 6]); 7 | console.log(output); // --> [2, 4, 6] 8 | -------------------------------------------------------------------------------- /exercises/116-filterEvenElements/solution.hide.js: -------------------------------------------------------------------------------- 1 | function filterEvenElements(arr) { 2 | // your code here 3 | return arr.filter(num => num % 2 === 0); 4 | } 5 | 6 | let output = filterEvenElements([2, 3, 4, 5, 6]); 7 | console.log(output); // --> [2, 4, 6] 8 | -------------------------------------------------------------------------------- /exercises/117-getLengthOfShortestElement/README.es.md: -------------------------------------------------------------------------------- 1 | # `117` getLengthOfShortestElement 2 | 3 | ## 📝 Instrucciones: 4 | 5 | 1. Escribe una función `getLengthOfShortestElement`. Dado un array, `getLengthOfShortestElement` retorna la longitud del string más corto en el array. 6 | 7 | ## 📎 Ejemplo: 8 | 9 | ```Js 10 | let output = getLengthOfShortestElement(['one', 'two', 'three']); 11 | console.log(output); // --> 3 12 | ``` 13 | 14 | ## 💡 Pista: 15 | 16 | + Si el array está vacío, debería retornar `0`. 17 | -------------------------------------------------------------------------------- /exercises/117-getLengthOfShortestElement/README.md: -------------------------------------------------------------------------------- 1 | # `117` getLengthOfShortestElement 2 | 3 | ## 📝 Instructions: 4 | 5 | 1. Write a function called `getLengthOfShortestElement`. Given an array, `getLengthOfShortestElement` returns the length of the shortest string in the given array. 6 | 7 | ## 📎 Example: 8 | 9 | ```Js 10 | let output = getLengthOfShortestElement(['one', 'two', 'three']); 11 | console.log(output); // --> 3 12 | ``` 13 | 14 | ## 💡 Hint: 15 | 16 | + if the given array is empty, it should return `0`. 17 | -------------------------------------------------------------------------------- /exercises/117-getLengthOfShortestElement/app.js: -------------------------------------------------------------------------------- 1 | function getLengthOfShortestElement(arr) { 2 | // your code here 3 | 4 | } 5 | 6 | let output = getLengthOfShortestElement(['one', 'two', 'three']); 7 | console.log(output); // --> 3 8 | -------------------------------------------------------------------------------- /exercises/117-getLengthOfShortestElement/solution.hide.js: -------------------------------------------------------------------------------- 1 | function getLengthOfShortestElement(arr) { 2 | // your code here 3 | if (arr.length < 1) return 0; 4 | 5 | let aux = 9999999999; 6 | for (let e of arr) { 7 | if (e.length < aux) aux = e.length; 8 | } 9 | return aux; 10 | } 11 | 12 | let output = getLengthOfShortestElement(['one', 'two', 'three']); 13 | console.log(output); // --> 3 14 | -------------------------------------------------------------------------------- /exercises/118-getLongestElement/README.es.md: -------------------------------------------------------------------------------- 1 | # `118` getLongestElement 2 | 3 | ## 📝 Instrucciones: 4 | 5 | 1. Escribe una función `getLongestElement`. Dado un array, `getLongestElement` retorna el string más largo dentro del array. 6 | 7 | ## 📎 Ejemplo: 8 | 9 | ```Js 10 | let output = getLongestElement(['one', 'two', 'three']); 11 | console.log(output); // --> 'three' 12 | ``` 13 | 14 | ## 💡 Pista: 15 | 16 | + Si tienen el mismo largo, entonces retorna el primer elemento encontrado. 17 | 18 | + Si el array está vacío, deberá retornar un string vacío. 19 | -------------------------------------------------------------------------------- /exercises/118-getLongestElement/app.js: -------------------------------------------------------------------------------- 1 | function getLongestElement(arr) { 2 | // your code here 3 | 4 | } 5 | 6 | let output = getLongestElement(['one', 'two', 'three']); 7 | console.log(output); // --> 'three' 8 | -------------------------------------------------------------------------------- /exercises/118-getLongestElement/solution.hide.js: -------------------------------------------------------------------------------- 1 | function getLongestElement(arr) { 2 | // your code here 3 | if (arr.length < 1) return ''; 4 | 5 | let aux = ''; 6 | for (let e of arr) { 7 | if (e.length > aux.length) aux = e; 8 | } 9 | 10 | return aux; 11 | } 12 | 13 | let output = getLongestElement(['one', 'two', 'three']); 14 | console.log(output); // --> 'three' 15 | -------------------------------------------------------------------------------- /exercises/119-findSmallestElement/README.es.md: -------------------------------------------------------------------------------- 1 | # `119` findSmallestElement 2 | 3 | ## 📝 Instrucciones: 4 | 5 | 1. Escribe una función llamada `findSmallestElement`. Dado un array de números, `findSmallestElement` retorna el número más pequeño dentro del array. 6 | 7 | ## 📎 Ejemplo: 8 | 9 | ```Js 10 | let output = findSmallestElement([4, 1, 9, 10]); 11 | console.log(output); // --> 1 12 | ``` 13 | 14 | ## 💡 Pista: 15 | 16 | + Si el array dado está vacío, debería retornar `0`. 17 | -------------------------------------------------------------------------------- /exercises/119-findSmallestElement/README.md: -------------------------------------------------------------------------------- 1 | # `119` findSmallestElement 2 | 3 | ## 📝 Instructions: 4 | 5 | 1. Write a function called `findSmallestElement`. Given an array of numbers, `findSmallestElement` returns the smallest number within the given array. 6 | 7 | ## 📎 Example: 8 | 9 | ```Js 10 | let output = findSmallestElement([4, 1, 9, 10]); 11 | console.log(output); // --> 1 12 | ``` 13 | 14 | ## 💡 Hint: 15 | 16 | + If the given array is empty, it should return `0`. 17 | -------------------------------------------------------------------------------- /exercises/119-findSmallestElement/app.js: -------------------------------------------------------------------------------- 1 | function findSmallestElement(arr) { 2 | // your code here 3 | 4 | } 5 | 6 | let output = findSmallestElement([4, 1, 9, 10]); 7 | console.log(output); // --> 1 -------------------------------------------------------------------------------- /exercises/119-findSmallestElement/solution.hide.js: -------------------------------------------------------------------------------- 1 | function findSmallestElement(arr) { 2 | // your code here 3 | if (arr.length < 1) return 0; 4 | 5 | let aux = 9999999999; 6 | for (let e of arr) { 7 | if (e < aux) aux = e; 8 | } 9 | 10 | return aux; 11 | } 12 | 13 | let output = findSmallestElement([4, 1, 9, 10]); 14 | console.log(output); // --> 1 15 | -------------------------------------------------------------------------------- /exercises/120-findShortestElement/app.js: -------------------------------------------------------------------------------- 1 | function findShortestElement(arr) { 2 | // your code here 3 | 4 | } 5 | 6 | let output = findShortestElement(['a', 'two', 'three']); 7 | console.log(output); // --> 'a' -------------------------------------------------------------------------------- /exercises/120-findShortestElement/solution.hide.js: -------------------------------------------------------------------------------- 1 | function findShortestElement(arr) { 2 | // your code here 3 | if (arr.length < 1) return ''; 4 | 5 | let aux = '999999999999999999999999999999'; 6 | for (let e of arr) { 7 | if (e.length < aux.length) aux = e; 8 | } 9 | return aux; 10 | } 11 | 12 | let output = findShortestElement(['a', 'two', 'three']); 13 | console.log(output); // --> 'a' 14 | -------------------------------------------------------------------------------- /exercises/121-getLargestElement/README.es.md: -------------------------------------------------------------------------------- 1 | # `121` getLargestElement 2 | 3 | ## 📝 Instrucciones: 4 | 5 | 1. Escribe una función `getLargestElement`. Dado un array, `getLargestElement` retorna el número más grande del array. 6 | 7 | ## 📎 Ejemplo: 8 | 9 | ```Js 10 | let output = getLargestElement([5, 2, 8, 3]); 11 | console.log(output); // --> 8; 12 | ``` 13 | 14 | ## 💡 Pista: 15 | 16 | + Si el array esta vacío, debe retornar `0`. 17 | -------------------------------------------------------------------------------- /exercises/121-getLargestElement/README.md: -------------------------------------------------------------------------------- 1 | # `121` getLargestElement 2 | 3 | ## 📝 Instructions: 4 | 5 | 1. Write a function called `getLargestElement`. Given an array, `getLargestElement` returns the largest number in the given array. 6 | 7 | ## 📎 Example: 8 | 9 | ```Js 10 | let output = getLargestElement([5, 2, 8, 3]); 11 | console.log(output); // --> 8; 12 | ``` 13 | 14 | ## 💡 Hint: 15 | 16 | + If the array is empty, it should return `0`. 17 | -------------------------------------------------------------------------------- /exercises/121-getLargestElement/app.js: -------------------------------------------------------------------------------- 1 | function getLargestElement(arr) { 2 | // your code here 3 | 4 | } 5 | 6 | let output = getLargestElement([5, 2, 8, 3]); 7 | console.log(output); // --> 8; -------------------------------------------------------------------------------- /exercises/121-getLargestElement/solution.hide.js: -------------------------------------------------------------------------------- 1 | function getLargestElement(arr) { 2 | // your code here 3 | if (arr.length < 1) return 0; 4 | 5 | let aux = arr[0]; 6 | for (let e of arr) { 7 | if (aux < e) aux = e; 8 | } 9 | return aux; 10 | } 11 | 12 | let output = getLargestElement([5, 2, 8, 3]); 13 | console.log(output); // --> 8; 14 | -------------------------------------------------------------------------------- /exercises/122-computeSumOfAllElements/README.es.md: -------------------------------------------------------------------------------- 1 | # `122` computeSumOfAllElements 2 | 3 | ## 📝 Instrucciones: 4 | 5 | 1. Escribe una función llamada `computeSumOfAllElements`. Dado una array de números, `computeSumOfAllElements` retorna la suma de todos los elementos del array. 6 | 7 | ## 📎 Ejemplo: 8 | 9 | ```Js 10 | let output = computeSumOfAllElements([1, 2, 3]) 11 | console.log(output); // --> 6 12 | ``` 13 | -------------------------------------------------------------------------------- /exercises/122-computeSumOfAllElements/README.md: -------------------------------------------------------------------------------- 1 | # `122` computeSumOfAllElements 2 | 3 | ## 📝 Instructions: 4 | 5 | 1. Write a function called `computeSumOfAllElements`. Given an array of numbers, `computeSumOfAllElements` returns the sum of all the elements in the given array. 6 | 7 | ## 📎 Example: 8 | 9 | ```Js 10 | let output = computeSumOfAllElements([1, 2, 3]) 11 | console.log(output); // --> 6 12 | ``` 13 | -------------------------------------------------------------------------------- /exercises/122-computeSumOfAllElements/app.js: -------------------------------------------------------------------------------- 1 | function computeSumOfAllElements(arr) { 2 | // your code here 3 | 4 | } 5 | 6 | let output = computeSumOfAllElements([1, 2, 3]) 7 | console.log(output); // --> 6 8 | -------------------------------------------------------------------------------- /exercises/122-computeSumOfAllElements/solution.hide.js: -------------------------------------------------------------------------------- 1 | function computeSumOfAllElements(arr) { 2 | // your code here 3 | let aux = 0; 4 | for (let e of arr) { 5 | aux += e; 6 | } 7 | return aux; 8 | } 9 | 10 | let output = computeSumOfAllElements([1, 2, 3]); 11 | console.log(output); // --> 6 12 | -------------------------------------------------------------------------------- /exercises/123-joinArraysOfArrays/README.es.md: -------------------------------------------------------------------------------- 1 | # `123` joinArrayOfArrays 2 | 3 | ## 📝 Instrucciones: 4 | 5 | 1. Escribe una función llamada `joinArrayOfArrays`. Dada una matriz (array de arrays), `joinArrayOfArrays` retorna un array único que contenga los elementos de los arrays anidados. 6 | 7 | ## 📎 Ejemplo: 8 | 9 | ```Js 10 | let output = joinArrayOfArrays([[1, 4], [true, false], ['x', 'y']]); 11 | console.log(output); // --> [1, 4, true, false, 'x', 'y'] 12 | ``` 13 | 14 | ## 💡 Pista: 15 | 16 | + Debes estar familiarizado con el método `concat()`. 17 | -------------------------------------------------------------------------------- /exercises/123-joinArraysOfArrays/README.md: -------------------------------------------------------------------------------- 1 | # `123` joinArrayOfArrays 2 | 3 | ## 📝 Instructions: 4 | 5 | 1. Write a function `joinArrayOfArrays`. Given a matrix (array of arrays), `joinArrayOfArrays` returns a single array containing the elements of the nested arrays. 6 | 7 | ## 📎 Example: 8 | 9 | ```Js 10 | let output = joinArrayOfArrays([[1, 4], [true, false], ['x', 'y']]); 11 | console.log(output); // --> [1, 4, true, false, 'x', 'y'] 12 | ``` 13 | 14 | ## 💡 Hint: 15 | 16 | + You should be familiar with the `concat()` method for this problem. 17 | -------------------------------------------------------------------------------- /exercises/123-joinArraysOfArrays/app.js: -------------------------------------------------------------------------------- 1 | function joinArrayOfArrays(arr) { 2 | // your code here 3 | 4 | } 5 | 6 | let output = joinArrayOfArrays([ 7 | [1, 4], 8 | [true, false], 9 | ['x', 'y'], 10 | ]); 11 | 12 | console.log(output); // --> [1, 4, true, false, 'x', 'y'] 13 | -------------------------------------------------------------------------------- /exercises/123-joinArraysOfArrays/solution.hide.js: -------------------------------------------------------------------------------- 1 | function joinArrayOfArrays(arr) { 2 | // your code here 3 | let aux = []; 4 | for (let e of arr) { 5 | aux = aux.concat(e); 6 | } 7 | return aux; 8 | } 9 | 10 | let output = joinArrayOfArrays([ 11 | [1, 4], 12 | [true, false], 13 | ['x', 'y'], 14 | ]); 15 | 16 | console.log(output); // --> [1, 4, true, false, 'x', 'y'] 17 | -------------------------------------------------------------------------------- /exercises/124-findShortestWordAmongMixedElements/app.js: -------------------------------------------------------------------------------- 1 | function findShortestWordAmongMixedElements(arr) { 2 | // your code here 3 | 4 | } 5 | 6 | let output = findShortestWordAmongMixedElements([4, 'two', 2, 'three']); 7 | console.log(output); // --> 'two' 8 | -------------------------------------------------------------------------------- /exercises/124-findShortestWordAmongMixedElements/solution.hide.js: -------------------------------------------------------------------------------- 1 | function findShortestWordAmongMixedElements(arr) { 2 | // your code here 3 | let shortestWord = ''; 4 | let shortestLength = Infinity; 5 | 6 | for (let element of arr) { 7 | if (typeof element === 'string' && element.length < shortestLength) { 8 | shortestWord = element; 9 | shortestLength = element.length; 10 | } 11 | } 12 | 13 | return shortestWord; 14 | } 15 | 16 | let output = findShortestWordAmongMixedElements([4, 'two', 2, 'three']); 17 | console.log(output); // --> 'two' 18 | -------------------------------------------------------------------------------- /exercises/125-findSmallestnumberAmongMixedElements/app.js: -------------------------------------------------------------------------------- 1 | function findSmallestNumberAmongMixedElements(arr) { 2 | // your code here 3 | 4 | } 5 | 6 | let output = findSmallestNumberAmongMixedElements([4, 'lincoln', 9, 'octopus']); 7 | console.log(output); // --> 4 8 | -------------------------------------------------------------------------------- /exercises/126-getLongestWordOfMixedElements/app.js: -------------------------------------------------------------------------------- 1 | function getLongestWordOfMixedElements(arr) { 2 | // your code here 3 | 4 | } 5 | 6 | let output = getLongestWordOfMixedElements([3, 'word', 5, 'up', 3, 1]); 7 | console.log(output); // --> 'word' 8 | -------------------------------------------------------------------------------- /exercises/126-getLongestWordOfMixedElements/solution.hide.js: -------------------------------------------------------------------------------- 1 | function getLongestWordOfMixedElements(arr) { 2 | // your code here 3 | let longestWord = ''; 4 | 5 | for (let element of arr) { 6 | if (typeof element === 'string' && element.length > longestWord.length) { 7 | longestWord = element; 8 | } 9 | } 10 | 11 | return longestWord; 12 | } 13 | 14 | let output = getLongestWordOfMixedElements([3, 'word', 5, 'up', 3, 1]); 15 | console.log(output); // --> 'word' 16 | -------------------------------------------------------------------------------- /exercises/127-getLargestNumberAmongMixedElements/app.js: -------------------------------------------------------------------------------- 1 | function getLargestNumberAmongMixedElements(arr) { 2 | // your code here 3 | 4 | } 5 | 6 | let output = getLargestNumberAmongMixedElements([3, 'word', 5, 'up', 3, 1]); 7 | console.log(output); // --> 5 8 | -------------------------------------------------------------------------------- /exercises/128-averageIntegers/README.es.md: -------------------------------------------------------------------------------- 1 | # `128` averageIntegers 2 | 3 | ## 📝 Instrucciones: 4 | 5 | 1. Usa el esqueleto proporcionado para escribir una implementación funcional. 6 | 7 | 2. Debes descubrir el promedio de una lista o array de números. 8 | 9 | 3. Utiliza la función `sum` para ayudarte a sumar los números de la lista. 10 | 11 | ## 💡 Pistas: 12 | 13 | + No dejes ninguna función en el esqueleto sin usar. 14 | 15 | + Comprueba que tu implementación funcione. 16 | 17 | + Ambas funciones reciben una `lista`/`array` de números. 18 | -------------------------------------------------------------------------------- /exercises/128-averageIntegers/README.md: -------------------------------------------------------------------------------- 1 | # `128` averageIntegers 2 | 3 | ## 📝 Instructions: 4 | 5 | 1. Use the skeleton provided to write a working implementation. 6 | 7 | 2. You need to discover the average of a list or array of numbers. 8 | 9 | 3. Use the `sum` function to help you sum the numbers in the list. 10 | 11 | ## 💡 Hints: 12 | 13 | + Do not leave any functions in the skeleton unused. 14 | 15 | + Test that your implementation works. 16 | 17 | + Both functions should receive an `array` of numbers. 18 | -------------------------------------------------------------------------------- /exercises/128-averageIntegers/app.js: -------------------------------------------------------------------------------- 1 | function average(arr) { 2 | // your code here 3 | 4 | } 5 | 6 | function sum(arr) { 7 | // your code here 8 | 9 | } 10 | 11 | console.log(average([1, 2])); // --> 1.5 12 | -------------------------------------------------------------------------------- /exercises/128-averageIntegers/solution.hide.js: -------------------------------------------------------------------------------- 1 | function average(arr) { 2 | // your code here 3 | return sum(arr) / arr.length; 4 | } 5 | 6 | function sum(arr) { 7 | // your code here 8 | return arr.reduce((a, b) => a + b, 0); 9 | } 10 | 11 | console.log(average([1, 2])); // --> 1.5 12 | -------------------------------------------------------------------------------- /exercises/129-calculateBillTotal/app.js: -------------------------------------------------------------------------------- 1 | function calculateBillTotal(preTaxAndTipAmount) { 2 | // your code here 3 | 4 | } 5 | 6 | let output = calculateBillTotal(20); 7 | console.log(output); // --> 24.9 8 | -------------------------------------------------------------------------------- /exercises/129-calculateBillTotal/solution.hide.js: -------------------------------------------------------------------------------- 1 | function calculateBillTotal(preTaxAndTipAmount) { 2 | // your code here 3 | let tax = preTaxAndTipAmount * 0.095; 4 | let tip = preTaxAndTipAmount * 0.15; 5 | return preTaxAndTipAmount + tax + tip; 6 | } 7 | 8 | let output = calculateBillTotal(20); 9 | console.log(output); // --> 24.9 10 | -------------------------------------------------------------------------------- /exercises/130-multiplyBetween/README.md: -------------------------------------------------------------------------------- 1 | # `130` multiplyBetween 2 | 3 | ## 📝 Instructions: 4 | 5 | 1. Write a function called `multiplyBetween`. Given 2 integers, `multiplyBetween` returns the product between the two given integers, beginning at `num1`, and excluding `num2`. 6 | 7 | ## 📎 Example: 8 | 9 | ```Js 10 | let output = multiplyBetween(2, 5); 11 | console.log(output); // --> 24 12 | ``` 13 | 14 | ## 💡 Hints: 15 | 16 | + The product between `1` and `4` is `1 * 2 * 3 = 6`. 17 | 18 | * If `num2` is not greater than `num1`, it should return `0`. 19 | -------------------------------------------------------------------------------- /exercises/130-multiplyBetween/app.js: -------------------------------------------------------------------------------- 1 | function multiplyBetween(num1, num2) { 2 | // your code here 3 | 4 | } 5 | 6 | let output = multiplyBetween(2, 5); 7 | console.log(output); // --> 24 8 | -------------------------------------------------------------------------------- /exercises/130-multiplyBetween/solution.hide.js: -------------------------------------------------------------------------------- 1 | function multiplyBetween(num1, num2) { 2 | // your code here 3 | if (num1 > num2) return 0; 4 | let aux = 1; 5 | for (let i = num1; i < num2; i++) aux *= i; 6 | return aux; 7 | } 8 | 9 | let output = multiplyBetween(2, 5); 10 | console.log(output); // --> 24 11 | -------------------------------------------------------------------------------- /exercises/131-computeSumBetween/README.md: -------------------------------------------------------------------------------- 1 | # `131` computeSumBetween 2 | 3 | ## 📝 Instructions: 4 | 5 | 1. Write a function called `computeSumBetween`. Given 2 integers, `computeSumBetween` returns the sum between the two given integers, beginning at `num1`, and excluding `num2`. 6 | 7 | ## 📎 Example: 8 | 9 | ```Js 10 | let output = computeSumBetween(2, 5); 11 | console.log(output); // --> 9 12 | ``` 13 | 14 | ## 💡 Hints: 15 | 16 | + The sum between `1` and `4` is `1 + 2 + 3 = 6`. 17 | 18 | + If `num2` is not greater than `num1`, it should return `0`. 19 | -------------------------------------------------------------------------------- /exercises/131-computeSumBetween/app.js: -------------------------------------------------------------------------------- 1 | function computeSumBetween(num1, num2) { 2 | // your code here 3 | 4 | } 5 | 6 | let output = computeSumBetween(2, 5); 7 | console.log(output); // --> 9 8 | -------------------------------------------------------------------------------- /exercises/131-computeSumBetween/solution.hide.js: -------------------------------------------------------------------------------- 1 | function computeSumBetween(num1, num2) { 2 | // your code here 3 | if (num1 > num2) return 0; 4 | let aux = 0; 5 | for (let i = num1; i < num2; i++) aux += i; 6 | return aux; 7 | } 8 | 9 | let output = computeSumBetween(2, 5); 10 | console.log(output); // --> 9 11 | -------------------------------------------------------------------------------- /exercises/132-computeSummationToN/README.es.md: -------------------------------------------------------------------------------- 1 | # `132` computeSummationToN 2 | 3 | ## 📝 Instrucciones: 4 | 5 | 1. Escribe una función llamada `computeSummationToN`. Dado un número, `computeSummationToN` retorna la suma de números secuenciales que conducen al número dado, comenzando en `0`. 6 | 7 | ## 📎 Ejemplo: 8 | 9 | ```Js 10 | let output = computeSummationToN(6); 11 | console.log(output); // --> 21 12 | ``` 13 | 14 | ## 💡 Pista: 15 | 16 | + Si `n = 4`, debes calcular la suma de `1 + 2 + 3 + 4` y retornar `10`. 17 | -------------------------------------------------------------------------------- /exercises/132-computeSummationToN/README.md: -------------------------------------------------------------------------------- 1 | # `132` computeSummationToN 2 | 3 | ## 📝 Instructions: 4 | 5 | 1. Write a function called `computeSummationToN`. Given a number, `computeSummationToN` returns the sum of sequential numbers leading up to the given number, beginning at `0`. 6 | 7 | ## 📎 Example: 8 | 9 | ```Js 10 | let output = computeSummationToN(6); 11 | console.log(output); // --> 21 12 | ``` 13 | 14 | ## 💡 Hint: 15 | 16 | + If `n = 4`, it should calculate the sum of `1 + 2 + 3 + 4`, and return `10`. 17 | -------------------------------------------------------------------------------- /exercises/132-computeSummationToN/app.js: -------------------------------------------------------------------------------- 1 | function computeSummationToN(n) { 2 | // your code here 3 | 4 | } 5 | 6 | let output = computeSummationToN(6); 7 | console.log(output); // --> 21 8 | 9 | -------------------------------------------------------------------------------- /exercises/132-computeSummationToN/solution.hide.js: -------------------------------------------------------------------------------- 1 | function computeSummationToN(n) { 2 | // your code here 3 | let sum = 0; 4 | 5 | for (let i = 1; i <= n; i++) { 6 | sum += i; 7 | } 8 | 9 | return sum; 10 | } 11 | 12 | let output = computeSummationToN(6); 13 | console.log(output); // --> 21 14 | -------------------------------------------------------------------------------- /exercises/133-convertScoreToGrade/app.js: -------------------------------------------------------------------------------- 1 | function convertScoreToGrade(score) { 2 | // your code here 3 | 4 | } 5 | 6 | let output = convertScoreToGrade(91); 7 | console.log(output); // --> 'A' 8 | -------------------------------------------------------------------------------- /exercises/133-convertScoreToGrade/solution.hide.js: -------------------------------------------------------------------------------- 1 | function convertScoreToGrade(score) { 2 | // your code here 3 | if (score > 100 || score < 0) return 'INVALID SCORE'; 4 | else { 5 | if (score >= 90 && score <= 100) return 'A'; 6 | if (score >= 80 && score <= 89) return 'B'; 7 | if (score >= 70 && score <= 79) return 'C'; 8 | if (score >= 60 && score <= 69) return 'D'; 9 | if (score >= 0 && score <= 59) return 'F'; 10 | } 11 | } 12 | 13 | let output = convertScoreToGrade(91); 14 | console.log(output); // --> 'A' 15 | -------------------------------------------------------------------------------- /exercises/134-convertScoreToGradeWithPlus/app.js: -------------------------------------------------------------------------------- 1 | function convertScoreToGradeWithPlusAndMinus(score) { 2 | // your code here 3 | 4 | } 5 | 6 | let output = convertScoreToGradeWithPlusAndMinus(91); 7 | console.log(output); // --> 'A-' 8 | -------------------------------------------------------------------------------- /exercises/135-computeFactorialOfN/app.js: -------------------------------------------------------------------------------- 1 | function computeFactorialOfN(n) { 2 | // your code here 3 | 4 | } 5 | 6 | let output = computeFactorialOfN(4); 7 | console.log(output); // --> 24 8 | -------------------------------------------------------------------------------- /exercises/135-computeFactorialOfN/solution.hide.js: -------------------------------------------------------------------------------- 1 | function computeFactorialOfN(n) { 2 | // your code here 3 | let aux = 1; 4 | for (let e = 1; e < n + 1; e++) aux *= e; 5 | return aux; 6 | } 7 | 8 | let output = computeFactorialOfN(4); 9 | console.log(output); // --> 24 10 | -------------------------------------------------------------------------------- /exercises/136-sumDigits/app.js: -------------------------------------------------------------------------------- 1 | function sumDigits(num) { 2 | // your code here 3 | 4 | } 5 | 6 | let output = sumDigits(-316); 7 | console.log(output); // --> 4 8 | -------------------------------------------------------------------------------- /exercises/136-sumDigits/solution.hide.js: -------------------------------------------------------------------------------- 1 | function sumDigits(num) { 2 | // your code here 3 | let numStr = num.toString(); 4 | let sum = 0; 5 | 6 | for (let i = 0; i < numStr.length; i++) { 7 | if (i === 0 && numStr[i] === "-") { 8 | sum -= Number(numStr[i + 1]); 9 | i++; 10 | } else { 11 | sum += Number(numStr[i]); 12 | } 13 | } 14 | 15 | return sum; 16 | } 17 | 18 | let output = sumDigits(-316); 19 | console.log(output); // --> 4 20 | -------------------------------------------------------------------------------- /exercises/137-computeCompoundInterest/app.js: -------------------------------------------------------------------------------- 1 | function computeCompoundInterest(principal, interestRate, compoundingFrequency, timeInYears) { 2 | // your code here 3 | 4 | } 5 | 6 | let output = computeCompoundInterest(1500, .043, 4, 6); 7 | console.log(output); // --> 438.83682213410543 8 | -------------------------------------------------------------------------------- /exercises/137-computeCompoundInterest/solution.hide.js: -------------------------------------------------------------------------------- 1 | function computeCompoundInterest( 2 | principal, 3 | interestRate, 4 | compoundingFrequency, 5 | timeInYears 6 | ) { 7 | // your code here 8 | let aux = 1 + interestRate / compoundingFrequency; 9 | let aux2 = aux ** (compoundingFrequency * timeInYears); 10 | let aux3 = principal * aux2; 11 | return aux3 - principal; 12 | } 13 | 14 | let output = computeCompoundInterest(1500, 0.043, 4, 6); 15 | console.log(output); // --> 438.83682213410543 16 | -------------------------------------------------------------------------------- /exercises/138-modulo/app.js: -------------------------------------------------------------------------------- 1 | function modulo(num1, num2) { 2 | // your code here 3 | 4 | } 5 | 6 | let output = modulo(25, 4); 7 | console.log(output); // --> 1 8 | -------------------------------------------------------------------------------- /exercises/139-multiply/README.es.md: -------------------------------------------------------------------------------- 1 | # `139` multiply 2 | 3 | ## 📝 Instrucciones: 4 | 5 | 1. Escribe una función llamada `multiply`. Dados 2 números enteros, `multiply` retorna su producto. 6 | 7 | ## 📎 Ejemplo: 8 | 9 | ```Js 10 | let output = multiply(4, 7); 11 | console.log(output); // --> 28 12 | ``` 13 | 14 | ## 💡 Pista: 15 | 16 | + No debes usar el operador de multiplicación (`*`) 17 | 18 | -------------------------------------------------------------------------------- /exercises/139-multiply/README.md: -------------------------------------------------------------------------------- 1 | # `139` multiply 2 | 3 | ## 📝 Instructions: 4 | 5 | 1. Write a function called `multiply`. Given 2 integers, `multiply` returns its product. 6 | 7 | ## 📎 Example: 8 | 9 | ```Js 10 | let output = multiply(4, 7); 11 | console.log(output); // --> 28 12 | ``` 13 | 14 | ## 💡 Hint: 15 | 16 | + DO NOT use the multiplication operator (`*`) 17 | 18 | -------------------------------------------------------------------------------- /exercises/139-multiply/app.js: -------------------------------------------------------------------------------- 1 | function multiply(num1, num2) { 2 | // your code here 3 | 4 | } 5 | 6 | let output = multiply(4, 7); 7 | console.log(output); // --> 28 8 | -------------------------------------------------------------------------------- /exercises/140-isOddWithoutModulo/README.es.md: -------------------------------------------------------------------------------- 1 | # `140` isOddWithoutModulo 2 | 3 | ## 📝 Instrucciones: 4 | 5 | 1. Escribe una función llamada `isOddWithoutModulo`. Dado un número, `isOddWithoutModulo` retorna `true` si el número pasado es impar. 6 | 7 | ## 📎 Ejemplo: 8 | 9 | ```Js 10 | let output = isOddWithoutModulo(17); 11 | console.log(output); // --> true 12 | ``` 13 | 14 | ## 💡 Pistas: 15 | 16 | + hazlo sin usar el operador de módulo (`%`). 17 | 18 | + Debería funcionar para números negativos y `0`. 19 | -------------------------------------------------------------------------------- /exercises/140-isOddWithoutModulo/README.md: -------------------------------------------------------------------------------- 1 | # `140` isOddWithoutModulo 2 | 3 | ## 📝 Instructions: 4 | 5 | 1. Write a function called `isOddWithoutModulo`. Given a number, `isOddWithoutModulo` returns `true` if the passed in number is odd. 6 | 7 | ## 📎 Example: 8 | 9 | ```Js 10 | let output = isOddWithoutModulo(17); 11 | console.log(output); // --> true 12 | ``` 13 | 14 | ## 💡 Hints: 15 | 16 | + It does so without using the modulo operator (`%`). 17 | 18 | + It should work for negative numbers and `0`. 19 | -------------------------------------------------------------------------------- /exercises/140-isOddWithoutModulo/app.js: -------------------------------------------------------------------------------- 1 | function isOddWithoutModulo(num) { 2 | // your code here 3 | 4 | } 5 | 6 | let output = isOddWithoutModulo(17); 7 | console.log(output); // --> true 8 | -------------------------------------------------------------------------------- /exercises/140-isOddWithoutModulo/solution.hide.js: -------------------------------------------------------------------------------- 1 | function isOddWithoutModulo(num) { 2 | // your code here 3 | let aux = true; 4 | if (num >= 0) { 5 | for (let x = 0; x <= num + 1; x += 2) { 6 | if (x === num) aux = false; 7 | } 8 | } else { 9 | for (let x = 0; x >= num - 1; x -= 2) { 10 | if (x === num) aux = false; 11 | } 12 | } 13 | return aux; 14 | } 15 | 16 | let output = isOddWithoutModulo(18); 17 | console.log(output); // --> false 18 | -------------------------------------------------------------------------------- /exercises/141-isEvenWithoutModulo/README.es.md: -------------------------------------------------------------------------------- 1 | # `141` isEvenWithoutModulo 2 | 3 | ## 📝 Instrucciones: 4 | 5 | 1. Escribe una función llamada `isEvenWithoutModulo`. Dado un número, `isEvenWithoutModulo` retorna `true` si es par. 6 | 7 | ## 📎 Ejemplo: 8 | 9 | ```Js 10 | let output = isEvenWithoutModulo(8); 11 | console.log(output); // --> true 12 | ``` 13 | 14 | ## 💡 Pistas: 15 | 16 | + Hazlo sin usar el operador de módulo (`%`). 17 | 18 | + Debería funcionar para números negativos y `0`. 19 | -------------------------------------------------------------------------------- /exercises/141-isEvenWithoutModulo/README.md: -------------------------------------------------------------------------------- 1 | # `141` isEvenWithoutModulo 2 | 3 | ## 📝 Instructions: 4 | 5 | 1. Write a function called `isEvenWithoutModulo`. Given a number, `isEvenWithoutModulo` returns `true` if it's even. 6 | 7 | ## 📎 Example: 8 | 9 | ```Js 10 | let output = isEvenWithoutModulo(8); 11 | console.log(output); // --> true 12 | ``` 13 | 14 | ## 💡 Hints: 15 | 16 | + It does so without using the modulo operator (`%`). 17 | 18 | + It should work for negative numbers and `0`. 19 | -------------------------------------------------------------------------------- /exercises/141-isEvenWithoutModulo/app.js: -------------------------------------------------------------------------------- 1 | function isEvenWithoutModulo(num) { 2 | // your code here 3 | 4 | } 5 | 6 | let output = isEvenWithoutModulo(8); 7 | console.log(output); // --> true 8 | -------------------------------------------------------------------------------- /exercises/141-isEvenWithoutModulo/solution.hide.js: -------------------------------------------------------------------------------- 1 | function isEvenWithoutModulo(num) { 2 | // your code here 3 | let aux = true; 4 | if (num >= 0) { 5 | for (let x = -1; x <= num + 1; x += 2) { 6 | if (x === num) aux = false; 7 | } 8 | } else { 9 | for (let x = -1; x >= num - 1; x -= 2) { 10 | if (x === num) aux = false; 11 | } 12 | } 13 | return aux; 14 | } 15 | 16 | let output = isEvenWithoutModulo(8); 17 | console.log(output); // --> true 18 | -------------------------------------------------------------------------------- /exercises/142.1-ArrayToObject/app.js: -------------------------------------------------------------------------------- 1 | function transformFirstAndLast(array) { 2 | // your code here 3 | 4 | } 5 | 6 | let arr = ['Queen', 'Elizabeth', 'Of Hearts', 'Beyonce']; 7 | console.log(transformFirstAndLast(arr)); // --> { Queen: "Beyonce" } 8 | -------------------------------------------------------------------------------- /exercises/142.1-ArrayToObject/solution.hide.js: -------------------------------------------------------------------------------- 1 | function transformFirstAndLast(array) { 2 | // your code here 3 | let aux = { [array[0]]: array[array.length - 1] }; 4 | 5 | return aux; 6 | } 7 | 8 | let arr = ['Queen', 'Elizabeth', 'Of Hearts', 'Beyonce']; 9 | console.log(transformFirstAndLast(arr)); // --> { Queen: "Beyonce" } 10 | -------------------------------------------------------------------------------- /exercises/142.2-ArrayToObject/app.js: -------------------------------------------------------------------------------- 1 | function fromListToObject(array) { 2 | // your code here 3 | 4 | } 5 | 6 | let output = fromListToObject([['make', 'Ford'], ['model', 'Mustang'], ['year', 1964]]) 7 | console.log(output) // --> { make: 'Ford', model: 'Mustang', year: 1964 } 8 | -------------------------------------------------------------------------------- /exercises/142.2-ArrayToObject/solution.hide.js: -------------------------------------------------------------------------------- 1 | function fromListToObject(array) { 2 | // your code here 3 | let aux = {}; 4 | for (let e of array) { 5 | aux[e[0]] = e[1]; 6 | } 7 | return aux; 8 | } 9 | 10 | let output = fromListToObject([ 11 | ['make', 'Ford'], 12 | ['model', 'Mustang'], 13 | ['year', 1964], 14 | ]); 15 | console.log(output); // --> { make: 'Ford', model: 'Mustang', year: 1964 } 16 | -------------------------------------------------------------------------------- /exercises/142.3-ArrayToObject/app.js: -------------------------------------------------------------------------------- 1 | function transformEmployeeData(array) { 2 | // your code here 3 | 4 | } 5 | -------------------------------------------------------------------------------- /exercises/143.1-ObjectToArray/README.es.md: -------------------------------------------------------------------------------- 1 | # `143.1` ObjectToArray 2 | 3 | ## 📝 Instrucciones: 4 | 5 | 1. Escribe una función llamada `getAllKeys` que devuelve un array de todas las keys del objeto de entrada. 6 | 7 | ## 📎 Ejemplo: 8 | 9 | ```js 10 | let output = getAllKeys({name: "Sam", age: 25, hasPets: true}); 11 | console.log(output); // --> [ 'name', 'age', 'hasPets' ] 12 | ``` 13 | 14 | ## 💡 Pistas: 15 | 16 | + No uses `Object.keys()` para resolver este problema. 17 | 18 | + Ten en cuenta que tu función debe poder manejar cualquier objeto que se le pase. 19 | -------------------------------------------------------------------------------- /exercises/143.1-ObjectToArray/README.md: -------------------------------------------------------------------------------- 1 | # `143.1` ObjectToArray 2 | 3 | ## 📝 Instructions: 4 | 5 | 1. Write a function called `getAllKeys` which returns an array of all the input object's keys. 6 | 7 | ## 📎 Example: 8 | 9 | ```js 10 | let output = getAllKeys({name: "Sam", age: 25, hasPets: true}); 11 | console.log(output); // --> [ 'name', 'age', 'hasPets' ] 12 | ``` 13 | 14 | ## 💡 Hints: 15 | 16 | + Do not use `Object.keys()` to solve this exercise. 17 | 18 | + Note that your function should be able to handle any object passed in it. 19 | -------------------------------------------------------------------------------- /exercises/143.1-ObjectToArray/app.js: -------------------------------------------------------------------------------- 1 | function getAllKeys(obj) { 2 | // your code here 3 | 4 | } 5 | 6 | let output = getAllKeys({name: "Sam", age: 25, hasPets: true}); 7 | console.log(output); // --> [ 'name', 'age', 'hasPets' ] 8 | -------------------------------------------------------------------------------- /exercises/143.1-ObjectToArray/solution.hide.js: -------------------------------------------------------------------------------- 1 | function getAllKeys(obj) { 2 | // your code here 3 | let arr = []; 4 | for(let element in obj) { 5 | arr.push(element); 6 | } 7 | return arr 8 | } 9 | 10 | let output = getAllKeys({ name: 'Sam', age: 25, hasPets: true }); 11 | console.log(output); // --> [ 'name', 'age', 'hasPets' ] 12 | -------------------------------------------------------------------------------- /exercises/143.2-ObjectToArray/README.es.md: -------------------------------------------------------------------------------- 1 | # `143.2` ObjectToArray 2 | 3 | ## 📝 Instrucciones: 4 | 5 | 1. Escribe una función llamada `listAllValues` que devuelva un array de todos los valores del objeto de entrada. 6 | 7 | ## 📎 Ejemplo: 8 | 9 | ```js 10 | let output = listAllValues({name: "Krysten", age: 33, hasPets: false}); 11 | console.log(output); // --> [ 'Krysten', 33, false ] 12 | ``` 13 | 14 | ## 💡 Pista: 15 | 16 | + Ten en cuenta que la entrada puede tener una cantidad diferente de keys y valores que el ejemplo dado. 17 | -------------------------------------------------------------------------------- /exercises/143.2-ObjectToArray/README.md: -------------------------------------------------------------------------------- 1 | # `143.2` ObjectToArray 2 | 3 | ## 📝 Instructions: 4 | 5 | 1. Write a function called `listAllValues` which returns an array of all the input object's values. 6 | 7 | ## 📎 Example: 8 | 9 | ```js 10 | let output = listAllValues({name: "Krysten", age: 33, hasPets: false}); 11 | console.log(output); // --> [ 'Krysten', 33, false ] 12 | ``` 13 | 14 | ## 💡 Hint: 15 | 16 | + Note that the input may have a different number of keys and values than the given sample. 17 | -------------------------------------------------------------------------------- /exercises/143.2-ObjectToArray/app.js: -------------------------------------------------------------------------------- 1 | function listAllValues(obj) { 2 | // your code here 3 | 4 | } 5 | 6 | let output = listAllValues({ name: 'Sam', age: 25, hasPets: true }); 7 | console.log(output); // --> [ 'Sam', 25, true ] 8 | -------------------------------------------------------------------------------- /exercises/143.2-ObjectToArray/solution.hide.js: -------------------------------------------------------------------------------- 1 | function listAllValues(obj) { 2 | // your code here 3 | let arr = []; 4 | for(let element in obj){ 5 | arr.push(obj[element]); 6 | } 7 | return arr 8 | } 9 | 10 | let output = listAllValues({ name: 'Sam', age: 25, hasPets: true }); 11 | console.log(output); // --> [ 'Sam', 25, true ] 12 | -------------------------------------------------------------------------------- /exercises/143.3-ObjectToArray/README.md: -------------------------------------------------------------------------------- 1 | # `143.3` ObjectToArray 2 | 3 | ## 📝 Instructions: 4 | 5 | 1. Write a function called `convertObjectToList` that converts a literal object into an array of arrays, like this: 6 | 7 | ## 📎 Example: 8 | 9 | ```js 10 | let output = convertObjectToList({ name: 'Holly', age: 35, role: 'producer' }); 11 | console.log(output); // --> [ ['name', 'Holly'], ['age', 35], ['role', 'producer'] ] 12 | ``` 13 | 14 | ## 💡 Hint: 15 | 16 | + Note that your function should handle ANY object like that one and not just the given sample. 17 | -------------------------------------------------------------------------------- /exercises/143.3-ObjectToArray/app.js: -------------------------------------------------------------------------------- 1 | function convertObjectToList(obj) { 2 | // your code here 3 | 4 | } 5 | 6 | let output = convertObjectToList({ name: 'Holly', age: 35, role: 'producer' }); 7 | console.log(output); // --> [ ['name', 'Holly'], ['age', 35], ['role', 'producer'] ] 8 | -------------------------------------------------------------------------------- /exercises/143.3-ObjectToArray/solution.hide.js: -------------------------------------------------------------------------------- 1 | function convertObjectToList(obj) { 2 | // your code here 3 | let result = []; 4 | for (let element in obj) { 5 | result.push([element, obj[element]]); 6 | } 7 | return result; 8 | } 9 | 10 | let output = convertObjectToList({ name: 'Holly', age: 35, role: 'producer' }); 11 | console.log(output); // --> [ ['name', 'Holly'], ['age', 35], ['role', 'producer'] ] 12 | 13 | -------------------------------------------------------------------------------- /exercises/144-getStringLength/README.es.md: -------------------------------------------------------------------------------- 1 | # `144` getStringLength 2 | 3 | ## 📝 Instrucciones: 4 | 5 | 1. Escribe una función llamada `getStringLength`. Dado un string, `getStringLength` retorna la longitud del string. 6 | 7 | ## 📎 Ejemplo: 8 | 9 | ```Js 10 | let output = getStringLength('hello'); 11 | console.log(output); // --> 5 12 | ``` 13 | 14 | ## 💡 Pistas: 15 | 16 | + NO uses el método `length`. 17 | 18 | + Puedes considerar usar `substring()` o `slice()` como alternativas. 19 | -------------------------------------------------------------------------------- /exercises/144-getStringLength/README.md: -------------------------------------------------------------------------------- 1 | # `144` getStringLength 2 | 3 | ## 📝 Instructions: 4 | 5 | 1. Write a function called `getStringLength`. Given a string, `getStringLength` returns the length of that string. 6 | 7 | ## 📎 Example: 8 | 9 | ```Js 10 | let output = getStringLength('hello'); 11 | console.log(output); // --> 5 12 | ``` 13 | 14 | ## 💡 Hints: 15 | 16 | * DO NOT use the `length` method. 17 | 18 | * You may consider using `substring()` or `slice()` as an alternative. 19 | -------------------------------------------------------------------------------- /exercises/144-getStringLength/app.js: -------------------------------------------------------------------------------- 1 | function getStringLength(string) { 2 | // your code here 3 | 4 | } 5 | 6 | let output = getStringLength('hello'); 7 | console.log(output); // --> 5 8 | -------------------------------------------------------------------------------- /exercises/144-getStringLength/solution.hide.js: -------------------------------------------------------------------------------- 1 | function getStringLength(string) { 2 | // your code here 3 | let count = 0; 4 | for (let char of string) { 5 | count++; 6 | } 7 | return count; 8 | } 9 | 10 | let output = getStringLength('hello'); 11 | console.log(output); // --> 5 12 | 13 | /* 14 | 15 | Solution #2: 16 | 17 | function getStringLength(string) { 18 | // your code here 19 | return [...string].reduce((a) => a + 1, 0); 20 | } 21 | 22 | let output = getStringLength('hello'); 23 | console.log(output); // --> 5 24 | 25 | */ 26 | -------------------------------------------------------------------------------- /exercises/145-GreetCustomers/app.js: -------------------------------------------------------------------------------- 1 | let customerData = { 2 | 'Joe': { 3 | visits: 1 4 | }, 5 | 'Carol': { 6 | visits: 2 7 | }, 8 | 'Howard': { 9 | visits: 3 10 | }, 11 | 'Carrie': { 12 | visits: 4 13 | } 14 | }; 15 | 16 | function greetCustomer(firstName) { 17 | let greeting = ''; 18 | // your code here 19 | 20 | return greeting; 21 | } 22 | 23 | console.log(greetCustomer('Joe')); // --> 'Welcome back, Joe! We're glad you liked us the first time!' 24 | -------------------------------------------------------------------------------- /exercises/146-flipPairs/README.md: -------------------------------------------------------------------------------- 1 | # `146` flipPairs 2 | 3 | ## 📝 Instructions: 4 | 5 | 1. Declare a function named `flipPairs`. 6 | 7 | 2. Function accepts a `string` input. 8 | 9 | 3. When calling the function, it returns a string with every ***pair*** of characters flipped including spaces. 10 | 11 | ## 📎 Example: 12 | 13 | ```Js 14 | let input = 'check out how interesting this problem is, it\'s insanely interesting!'; 15 | let output = flipPairs(input); 16 | console.log(output); // --> hcce kuo toh wnietertsni ghtsip orlbmei ,si 't sniasenyli tnreseitgn! 17 | ``` 18 | -------------------------------------------------------------------------------- /exercises/146-flipPairs/app.js: -------------------------------------------------------------------------------- 1 | function flipPairs(input) { 2 | // your code here 3 | 4 | } 5 | 6 | let input = "Can you see what this is about?"; 7 | let output = flipPairs(input); 8 | console.log(output); // --> aC noy ues ehwtat ih ssia obtu? 9 | -------------------------------------------------------------------------------- /exercises/146-flipPairs/solution.hide.js: -------------------------------------------------------------------------------- 1 | function flipPairs(input) { 2 | // your code here 3 | let result = input.replace(/(.)(.)/g, '$2$1'); 4 | return result; 5 | } 6 | 7 | let input = "Can you see what this is about?"; 8 | let output = flipPairs(input); 9 | console.log(output); // --> aC noy ues ehwtat ih ssia obtu? 10 | -------------------------------------------------------------------------------- /exercises/147-flipEveryNChars/app.js: -------------------------------------------------------------------------------- 1 | function flipEveryNChars(input, n) { 2 | // your code here 3 | 4 | } 5 | 6 | let input = 'a short example'; 7 | let output = flipEveryNChars(input, 5); 8 | console.log(output); // --> ohs axe trelpma 9 | -------------------------------------------------------------------------------- /exercises/147-flipEveryNChars/solution.hide.js: -------------------------------------------------------------------------------- 1 | function flipEveryNChars(input, n) { 2 | // your code here 3 | let reges = `(.{${n}})`; 4 | let parsed = new RegExp(reges); 5 | 6 | let result = input 7 | .split(parsed) 8 | .map((e) => e.split('').reverse().join('')) 9 | .join(''); 10 | return result; 11 | } 12 | 13 | let input = 'a short example'; 14 | let output = flipEveryNChars(input, 5); 15 | console.log(output); // --> ohs axe trelpma 16 | -------------------------------------------------------------------------------- /exercises/148-detectOutlierValue/app.js: -------------------------------------------------------------------------------- 1 | function detectOutlierValue(string) { 2 | // your code here 3 | 4 | } 5 | 6 | // Third number is odd, while the rest of the numbers are even 7 | console.log(detectOutlierValue("2 4 7 8 10")); // --> 3 8 | 9 | // Second number is even, while the rest of the numbers are odd 10 | console.log(detectOutlierValue("1 10 1 1")) // --> 2 11 | -------------------------------------------------------------------------------- /exercises/149-findPairForSum/README.es.md: -------------------------------------------------------------------------------- 1 | # `149` findPairForSum 2 | 3 | ## 📝 Instrucciones: 4 | 5 | 1. Escribe una función llamada `findPairForSum`. Dada una lista de números enteros positivos y un total determinado, encuentra el primer par de números que sumen el total determinado. 6 | 7 | ## 📎 Ejemplo: 8 | 9 | ```Js 10 | let pair = findPairForSum([3, 34, 4, 12, 5, 2], 9); 11 | console.log(pair); // --> [4, 5] 12 | ``` 13 | -------------------------------------------------------------------------------- /exercises/149-findPairForSum/README.md: -------------------------------------------------------------------------------- 1 | # `149` findPairForSum 2 | 3 | ## 📝 Instructions: 4 | 5 | 1. Write a function called `findPairForSum`. Given a list of positive integers and a total objective, find the first pair of numbers that add up to the total objective. 6 | 7 | ## 📎 Example: 8 | 9 | ```Js 10 | let pair = findPairForSum([3, 34, 4, 12, 5, 2], 9); 11 | console.log(pair); // --> [4, 5] 12 | ``` 13 | -------------------------------------------------------------------------------- /exercises/149-findPairForSum/app.js: -------------------------------------------------------------------------------- 1 | function findPairForSum(array, number) { 2 | // your code here 3 | 4 | } 5 | 6 | let pair = findPairForSum([3, 34, 4, 12, 5, 2], 9); 7 | console.log(pair); // --> [4, 5] 8 | -------------------------------------------------------------------------------- /exercises/149-findPairForSum/solution.hide.js: -------------------------------------------------------------------------------- 1 | function findPairForSum(array, number) { 2 | // your code here 3 | for (let i = 0; i < array.length; i++) { 4 | for (let j = 1; j < array.length; j++) { 5 | if (array[i] + array[j] === number) { 6 | return [array[i], array[j]] 7 | } 8 | } 9 | } 10 | } 11 | 12 | let pair = findPairForSum([3, 34, 4, 12, 5, 2], 9); 13 | console.log(pair); // --> [4, 5] 14 | -------------------------------------------------------------------------------- /exercises/150-isRotated/app.js: -------------------------------------------------------------------------------- 1 | function isRotated(str1, str2) { 2 | // your code here 3 | 4 | } 5 | 6 | console.log(isRotated('hello world', 'orldhello w')); // --> true 7 | console.log(isRotated('hello world', 'omrel wp')); // --> false 8 | 9 | -------------------------------------------------------------------------------- /exercises/151-search/app.js: -------------------------------------------------------------------------------- 1 | function search(array, value) { 2 | // your code here 3 | 4 | } 5 | 6 | let arr = [1, 3, 16, 22, 31, 33, 34] 7 | console.log(search(arr, 31)); // --> 4 8 | -------------------------------------------------------------------------------- /exercises/151-search/solution.hide.js: -------------------------------------------------------------------------------- 1 | function search(array, value) { 2 | // your code here 3 | let start = 0 4 | let end = array.length - 1; 5 | while (start <= end) { 6 | let mid = Math.floor((start + end) / 2); 7 | if (array[mid] === value) return mid; 8 | else if (array[mid] < value) 9 | start = mid + 1; 10 | else 11 | end = mid - 1; 12 | } 13 | return null; 14 | } 15 | 16 | let arr = [1, 3, 16, 22, 31, 33, 34]; 17 | console.log(search(arr, 31)); // --> 4 18 | -------------------------------------------------------------------------------- /exercises/152-isogram/app.js: -------------------------------------------------------------------------------- 1 | function isIsogram(text) { 2 | // your code here 3 | 4 | } 5 | 6 | console.log(isIsogram("Camile")); // --> true 7 | console.log(isIsogram("Camille")); // --> false 8 | -------------------------------------------------------------------------------- /exercises/152-isogram/solution.hide.js: -------------------------------------------------------------------------------- 1 | function isIsogram(text) { 2 | // your code here 3 | let lowerCaseText = text.toLowerCase() 4 | 5 | const chars = {}; 6 | for (const char of lowerCaseText) { 7 | chars[char] = (chars[char] || 0) + 1; 8 | } 9 | let result = Object.entries(chars) 10 | .filter((char) => char[1] > 1) 11 | .map((char) => char[0]); 12 | if (result.length > 0) return false; 13 | else return true; 14 | } 15 | 16 | console.log(isIsogram('Camile')); // --> true 17 | console.log(isIsogram('Camille')); // --> false 18 | -------------------------------------------------------------------------------- /exercises/154-longestPalindrome/app.js: -------------------------------------------------------------------------------- 1 | function findLongestPalindrome(sentence) { 2 | // your code here 3 | 4 | } 5 | 6 | function reverseString(string) { 7 | // your code here 8 | 9 | } 10 | 11 | function isPalindrome(word) { 12 | // your code here 13 | 14 | } 15 | 16 | let output = findLongestPalindrome("My dad is a racecar athlete"); 17 | console.log(output); // --> "a racecar a" 18 | -------------------------------------------------------------------------------- /preview.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/4GeeksAcademy/master-javascript-programming-exercises/7c797ab7b5df55de872ae820249c50bd9dd0a6fa/preview.jpeg --------------------------------------------------------------------------------