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
/*! Hint.css - v3.0.0 - 2023-11-29 | |
* https://kushagra.dev/lab/hint/ | |
* Copyright (c) 2023 Kushagra Gour | |
*/ | |
/*! | |
Updated from elisavetTriant (2024-10-13) | |
https://github.com/elisavetTriant | |
#-----Key changes-----# |
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
import L from "leaflet"; //don't forget to install Leaflet with npm install leaflet | |
class LeafletMap { | |
constructor() { | |
document.querySelectorAll(".leaflet-map").forEach(el => { | |
this.new_map(el); | |
}) | |
} | |
new_map($el) { |
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
//#3 create two classes: an Animal class and a Mamal class. | |
// create a cow that accepts a name, type and color and has a sound method that moo's her name, type and color. | |
class Animal { | |
constructor(name, type, color) { | |
this.name = name; | |
this.type = type; | |
this.color = color; | |
} | |
} |
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 convertNumberToUnits(n) { | |
let numberToBreakUp = n.toString(); | |
let unitsArray = numberToBreakUp.split(""); | |
return unitsArray.map((item, index, array) => { | |
let zeros = '0'.repeat(array.length - index - 1); | |
return parseInt(item.concat(zeros), 10); | |
} | |
); | |
} |
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
/*JavaScript Algorithms and Data Structures Projects: Palindrome Checker | |
Return true if the given string is a palindrome. Otherwise, return false. | |
A palindrome is a word or sentence that's spelled the same way both forward and backward, ignoring punctuation, case, and spacing. | |
Note | |
You'll need to remove all non-alphanumeric characters (punctuation, spaces and symbols) and turn everything into the same case (lower or upper case) in order to check for palindromes. | |
We'll pass strings with varying formats, such as "racecar", "RaceCar", and "race CAR" among others. | |
We'll also pass strings with special symbols, such as "2A3*3a2", "2A3 3a2", and "2_A3*3#A2". | |
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/javascript-algorithms-and-data-structures-projects/palindrome-checker*/ | |
function palindrome(str) { |
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
/*Intermediate Algorithm Scripting: Arguments Optional | |
Create a function that sums two arguments together. If only one argument is provided, then return a function that expects one argument and returns the sum. | |
For example, addTogether(2, 3) should return 5, and addTogether(2) should return a function. | |
Calling this returned function with a single argument will then return the sum: | |
var sumTwoAnd = addTogether(2); | |
sumTwoAnd(3) returns 5. | |
If either argument isn't a valid number, return undefined. | |
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/arguments-optional/ | |
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Conditional_Operator*/ |
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
/* | |
Intermediate Algorithm Scripting: Make a Person | |
Fill in the object constructor with the following methods below: | |
getFirstName() getLastName() getFullName() setFirstName(first) setLastName(last) setFullName(firstAndLast) | |
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/make-a-person/ | |
*/ | |
var Person = function(firstAndLast) { | |
// Complete the method below and implement the others similarly | |
var names = firstAndLast.split(" "); |
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
/*Intermediate Algorithm Scripting: Map the Debris | |
Return a new array that transforms the elements' average altitude into their orbital periods (in seconds). | |
The array will contain objects in the format {name: 'name', avgAlt: avgAlt}. | |
You can read about orbital periods on Wikipedia. | |
The values should be rounded to the nearest whole number. The body being orbited is Earth. | |
The radius of the earth is 6367.4447 kilometers, and the GM value of earth is 398600.4418 km3s-2. | |
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/map-the-debris*/ | |
function orbitalPeriod(arr) { | |
const GM = 398600.4418; //in km3s-2. |
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
/*Intermediate Algorithm Scripting: Everything Be True | |
Check if the predicate (second argument) is truthy on all elements of a collection (first argument). | |
In other words, you are given an array collection of objects. | |
The predicate pre will be an object property and you need to return true if its value is truthy. Otherwise, return false. | |
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/everything-be-true | |
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean | |
https://www.sitepoint.com/javascript-truthy-falsy/ | |
*/ | |
function truthCheck(collection, pre) { |
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
/* | |
Intermediate Algorithm Scripting: Binary Agents | |
Return an English translated sentence of the passed binary string. | |
The binary string will be space separated. | |
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/binary-agents | |
More on converting between binary and readable strings on: https://ourcodeworld.com/articles/read/380/how-to-convert-a-binary-string-into-a-readable-string-and-vice-versa-with-javascript*/ | |
function binaryAgent(str) { | |
return str.split(" ").map(function (elem) { | |
return String.fromCharCode(parseInt(elem, 2)); |
NewerOlder