- No additional setup required
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ************************************************************************************ | |
// https://www.codewars.com/kata/5848565e273af816fb000449/javascript | |
// Description: | |
// Encrypt this! | |
// You want to create secret messages which can be deciphered by the Decipher this! kata. | |
// Here are the conditions: | |
// Your message is a string containing space separated words. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ************************************************************************************ | |
// https://www.codewars.com/kata/the-hashtag-generator | |
// The marketing team is spending way too much time typing in hashtags. | |
// Let's help them with our own Hashtag Generator! | |
// Here's the deal: | |
// It must start with a hashtag (#). | |
// All words must have their first letter capitalized. | |
// If the final result is longer than 140 chars it must return false. |
- Calculate the total population in the given array (
data
):
const data = [
{
country: 'USA',
pop: 340,
},
{
country: 'France',
- mutates the original array - to prevent it, make a copy (
const sorted = origArr.slice().sort()
orconst sorted1 = [...origArr]
) of the array and then sort the copy - makes a specific order of elements
- returns array
- sorts by a string value (even if it's an array of numbers)
There's plenty of ways to sort arrays in JavaScript (and using .sort()
is probably one of the slowest ones, but it is important to understand it and how it works).
const arrOfStrings = ['cat', 'wolf', 'yo', 'animal'];
-
Exercise 1: Using the array (
arrOfStrings
), sort an array from shortest string to the longest. -
Exercise 2: Using the same arr (
arrOfStrings
), sort its elements alphabetically. -
Exercise 3: Sort the objects in the array by age, in descending order.
- Given an array of numbers, filter out the numbers that are not even, and are less than 100.
const numbers = [1, 60, 112, 123, 100, 99, 73, ];
// ... your code here
- From the given array of people, get the people who are allowed to consume alcoholic beverages (based on the US law). Bonus: Get just their names, we don't need their age.
NewerOlder