This file contains hidden or 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
const days = ["Lun","Mar","Mie","Juv","Vie","Sab","Dom"] | |
const userSchedule = [ | |
[], | |
['17:00', '18:00', '19:00'], | |
['17:00', '18:00', '19:00'], | |
['17:00'], | |
['17:00', '18:00', '19:00'], | |
['17:00', '18:00', '19:00'], | |
[] | |
]; |
This file contains hidden or 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
//Input | |
let d = '210614164612'; | |
//Conver | |
let year = d.slice(0, 2); | |
let month = d.slice(2, 4); | |
let day = d.slice(4, 6); | |
let hour = d.slice(6, 8); | |
let min = d.slice(8, 10); | |
let sec = d.slice(10,12); |
This file contains hidden or 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
const {allEqual} = require('js-packtools')(); | |
//👇🏻 Check if all the elements of an array are equal | |
[1, 1, 1, 1, 1, 1, 1, 1].allEqual(); //⇒ true | |
//👇🏻 If at least one is different then it returns false | |
[1, 1, 1, 1, 2, 1, 1, 1].allEqual(); //⇒ false | |
//💡 the same results in a simpler way |
This file contains hidden or 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
const jsPackTools = require('js-packtools')(); | |
//👇🏻 Check if all the elements of an array are equal | |
jsPackTools.allEqual([1, 1, 1, 1, 1, 1, 1, 1]); //⇒ true | |
//👇🏻 If at least one is different then it returns false | |
jsPackTools.allEqual([1, 1, 1, 1, 2, 1, 1, 1]); //⇒ false |
This file contains hidden or 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
const { capitalLetter } = require('js-packtools')(); | |
//👇🏻 Capitalize only the first letter | |
capitalLetter('hello word'); //⇒ Hello word | |
//👇🏻 Capitalize all the first letter of each word in the sentence | |
capitalLetter('hello word', true); //⇒ Hello Word | |
//💡 ---- tips: you can use prototyping ---- | |
This file contains hidden or 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
const jsPacktools = require("js-packtools")(); | |
//👇🏻 Capitalize only the first letter | |
jsPacktools.capitalLetter('hello word'); //⇒ Hello word | |
//👇🏻 Capitalize all the first letter of each word in the sentence | |
jsPacktools.capitalLetter('hello word', true); //⇒ Hello Word | |
//📎 This is the most basic way in which this function can be used. |
This file contains hidden or 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
const getAllIndexText = (str, letter, caseSensitive = false) => { | |
//all lowercase letters | |
if (caseSensitive) { | |
str = str.toLowerCase(); | |
letter = letter.toLowerCase(); | |
} | |
let arPosition = []; | |
while (str.indexOf(letter) > -1) { | |
arPosition.push(str.indexOf(letter)); | |
str = str.replace(letter, '__'); |
This file contains hidden or 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
const assert = require('assert'); | |
selfSum = a => (Array.isArray(a) && eval(a.filter(n => typeof n === 'number').join('+'))) | 0; | |
describe('TEST # 1 - selfSum()', function () { | |
it('should, sum all numeric elements', function () { | |
let arr = [1,2,3,4,5,6,'A']; | |
assert.equal(selfSum(arr),21); | |
}); |
This file contains hidden or 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
"use strict"; | |
function _instanceof(left, right) { | |
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) { | |
return !!right[Symbol.hasInstance](left); | |
} else { | |
return left instanceof right; | |
} | |
} | |
function _classCallCheck(instance, Constructor) { |
This file contains hidden or 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 pad (n, width, z) { | |
z = z || '0'; | |
n = n + ''; | |
return n.length >= width ? n : new Array(width - n.length + 1).join(z) + n; | |
} | |
function toFormattedDateString(timestamp, includeTime){ | |
if(typeof includeTime == 'undefined'){ | |
includeTime = true; | |
} |
NewerOlder