The web is built with HTML strings like "Yay" which draws Yay as italic text.
In this example, the "i" tag makes and which surround the word "Yay".
Given tag and word strings, create the HTML string with tags around the word,
e.g.: <i>Yay</i>
makeTags(";","Text 2") -> "<;>Text 2</;>"
Given a string, return the string made of its first two chars, so the String "Hello" yields "He". If the string is shorter than length 2, return whatever there is, so "X" yields "X", and the empty string "" yields the empty string "".
firstTwo("Hello") → "He"
firstTwo("abcdefg") → "ab"
firstTwo("ab") → "ab"
Given 2 strings, a and b, return a string of the form short+long+short, with the shorter string on the outside and the longer string on the inside. The strings will not be the same length, but they may be empty (length 0).
comboString("Hello", "hi") → "hiHellohi"
comboString("hi", "Hello") → "hiHellohi"
comboString("aaa", "b") → "baaab"
Given a string and an index, return char of string at the given index position.
If index is negative — start from the end of string.
If index is bigger(or for negative — smaller) than string length — loop over string characters again.
If string is null
— return "null"
.
charAt("Hello", 0) -> "H"
charAt("Hello", -1) -> "o"
charAt("Hello", -6) -> "o"
charAt("Hello", 6) -> "e"
Given 2 arrays of ints, a and b, return true if their first or last elements are same. Both arrays will have 1 or more elements.
commonEnd([1, 2, 3], [7, 3]) → true
commonEnd([1, 2, 3], [7, 3, 2]) → false
commonEnd([1, 2, 3], [1, 3]) → true
commonEnd([3,4,5], [1,2,3]) → true
Given an array of ints, return a new array with the elements in reverse order, so {1, 2, 3} becomes {3, 2, 1}.
reverse([1, 2, 3]) → [3, 2, 1]
reverse([5, 11, 9]) → [9, 11, 5]
reverse([7, 0, 0, 1]) → [1, 0, 0, 7]
Return the number of even ints in the given array. (0
is also even)
countEvens([2, 1, 2, 3, 4]) → 3
countEvens([2, 2, 0]) → 3
countEvens([1, 3, -5]) → 0
Return an array that contains the exact same numbers as the given array, but rearranged so that all the even numbers come before all the odd numbers. Order of numbers should be preserved.
evenOdd([1, 0, 1, 0, 0, 1, 1]) → [0, 0, 0, 1, 1, 1, 1]
evenOdd([3, 3, 2]) → [2, 3, 3]
evenOdd([2, 2, 2]) → [2, 2, 2]
evenOdd([2, 6, 4, 3, 1, 5, 8, 10] → [2, 6, 4, 8, 10, 3, 1, 5]
Parse given URL and extract scheme
, host
and port
. Return an array with extracted data
in following order: ['scheme', 'host', 'port']
.
If any of returning parameters could not be identified - return empty string for that parameter.
extractData("http://www.trarara.com/posts) -> ["http","www.tratata.com",""]
extractData("ftp://example.com:20) -> ["ftp","example.com","20"]
extractData("www.example.com) -> ["","www.example.com",""]
Return given text, without leading and trailing whitespaces in each line. Be sure not to remove whitespaces inside sentences.
Do not use String.trim()
method. Implement your own solution based on RegExp.
trim(" Text is here. ") -> "Text is here."
trim("") -> ""
trim("Text") -> "Text"