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
<html> | |
<head> | |
<meta name="viewport" content="width=device-width"> | |
<style> | |
div.container { | |
width:100%; | |
} | |
header, footer { | |
padding: 2em; |
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
<header> | |
<link href="https://fonts.googleapis.com/css?family=Enriqueta" rel="stylesheet"> | |
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" integrity="sha384-wvfXpqpZZVQGK6TAh5PVlGOfQNHSoD2xbE+QkPxCAFlNEevoEH3Sl0sibVcOQVnN" crossorigin="anonymous"> | |
</header> | |
<div class = "pageOne text-center" id="p1"> | |
<ul class = "nav nav-pills"> | |
<li> | |
<a href="#p1">Andrii Bozhenko</a> | |
</li> |
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
var contacts = [ | |
{ | |
"firstName": "Akira", | |
"lastName": "Laine", | |
"number": "0543236543", | |
"likes": ["Pizza", "Coding", "Brownie Points"] | |
}, | |
{ | |
"firstName": "Harry", | |
"lastName": "Potter", |
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
/* | |
Bike constructor with a private property called "gear" | |
and two public methods called "getGear" and "setGear" | |
to get and set that value. | |
*/ | |
var Bike = function() { | |
var gear; | |
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
function palindrome(str) { | |
var result = str.replace(/[\W_]/g, '').toLowerCase(); // find and remove all non-alphanumeric characters (punctuation, spaces and symbols) from a string, replace them with ''(no-space), and turn everything lower case | |
var reversed = result.split('').reverse().join(''); // split a "result" into an array of strings (separator is '', no-space), reverse it and join all elements of an array into a string and return this string. | |
if (reversed === result) { | |
return true; | |
} | |
else { | |
return false; |
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
function findLongestWord(str) { | |
var array = str.split(' '); // split a string object into an array of strings (separator is ' ') | |
var longestWord = 0; | |
for (var i = 0; i < array.length; i++){ | |
if (array[i].length > longestWord) { // check if length (its type=number) of each string in the array is bigger than the next one | |
longestWord = array[i].length; // [if true] assign bigger number ([i].length) to 'longestWord' variable | |
} | |
} |
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
/* | |
Return the provided string with the first letter of each word capitalized. | |
Make sure the rest of the word is in lower case. | |
*/ | |
function titleCase(str) { | |
function toUpper (word){ //https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace | |
return word.toUpperCase(); //"The important thing here is that additional operations are needed on the matched item before | |
} // it is given back as a replacement. The replacement function accepts the matched snippet as its parameter, and uses it to transform the case" |
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
//Return an array consisting of the largest number from each provided sub-array. | |
function largestOfFour(arr) { | |
var largest = arr.map(function(val){ | |
return Math.max(...val); // ES6 syntax, equivalent to "return Math.max.apply(null, val);" | |
}); | |
return largest; | |
} |
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
/* | |
Check if a string (first argument, str) ends with the given target string (second argument, target). | |
This challenge can be solved with the .endsWith() method, which was introduced in ES2015. | |
But for the purpose of this challenge, we would like you to use one of the JavaScript substring methods instead. | |
*/ | |
function confirmEnding(str, target) { | |
var lastLetter = str.substr(-1); //get last character of str by its index (-1) |
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
/* assignment: Repeat a given string (first argument) num times (second argument). | |
Return an empty string if num is not a positive number. | |
*/ | |
function repeatStringNumTimes(str, num) { | |
if (num <= 0) { | |
return ""; // return empty string | |
} | |
return str.repeat(num); // The repeat() method constructs and returns a new string which contains the specified number (num) of copies | |
} // of the string on which it was called, concatenated together. |
OlderNewer