Skip to content

Instantly share code, notes, and snippets.

@AndriiBozh
AndriiBozh / index.html
Created December 20, 2017 20:53
Tribute Page
<html>
<head>
<meta name="viewport" content="width=device-width">
<style>
div.container {
width:100%;
}
header, footer {
padding: 2em;
@AndriiBozh
AndriiBozh / index.html
Created December 22, 2017 14:06
Portfolio Webpage
<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>
@AndriiBozh
AndriiBozh / profile_lookup.txt
Last active January 1, 2018 12:26
Profile Lookup (freeCodeCamp puzzle)
var contacts = [
{
"firstName": "Akira",
"lastName": "Laine",
"number": "0543236543",
"likes": ["Pizza", "Coding", "Brownie Points"]
},
{
"firstName": "Harry",
"lastName": "Potter",
@AndriiBozh
AndriiBozh / bike_gear.txt
Last active January 1, 2018 12:27
Setting Gear (freeCodeCamp challenge)
/*
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;
@AndriiBozh
AndriiBozh / check_for_palindromes.txt
Created January 7, 2018 13:57
Check For Palindromes (freeCodeCamp challenge)
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;
@AndriiBozh
AndriiBozh / find_the_longest_word.txt
Created January 7, 2018 18:32
Find the Longest Word in a String (freeCodeCamp challenge)
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
}
}
@AndriiBozh
AndriiBozh / to_upper_case.txt
Created January 8, 2018 23:54
To Upper Case (freeCodeCamp challenge)
/*
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"
@AndriiBozh
AndriiBozh / largest_numbers.txt
Created January 10, 2018 15:49
Return Largest Numbers in Arrays (freeCodeCamp challenge)
//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;
}
@AndriiBozh
AndriiBozh / confirm_ending.txt
Created January 11, 2018 22:10
Confirm the Ending (freeCodeCamp challenge)
/*
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)
@AndriiBozh
AndriiBozh / repeat_a_string.txt
Created January 14, 2018 13:33
Repeat a String (freeCodeCamp challenge)
/* 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.