M

@miguladg

Are they the "same"?

NodeJS
1 year ago
function comp(array1, array2){ console.log('array1:', array1, 'array2:', array2) if (!Array.isArray(array1) || !Array.isArray(array2)) { return false; } for (let i = 0; i < array1.length; i++ ) { // console.log(i); if ( Math.pow(array1[i], 2) != array2[i + 1] ) { console.log('false');

Arrow Function 19

NodeJS
1 year ago
const event = { name: 'Birthday Party', guestList: ['Andrew', 'Jen', 'Mike'], printGuestList() { console.log('Guest list for ' + this.name) this.guestList.forEach((guest)=> { console.log(guest + 'is attending ' + this.name) }) }

Rot13

NodeJS
1 year ago
function rot13(message){ console.log(message) const alphabet = 'abcdefghijklmnopqrstuvwxyz'.split(''); const alphabetMayo = 'abcdefghijklmnopqrstuvwxyz'.toUpperCase().split(''); let rot = [] let fin = [] const arrayMe = message.toLowerCase().split('') // console.log(message)

So Many Permutations!

NodeJS
1 year ago
function permutations(string) { // Función recursiva para generar permutaciones function generatePerms(str) { if (str.length <= 1) { // console.log('generatePerms') return [str]; } let allPerms = [];

Felipe

Python
1 year ago
def solution(args): print(args) # your code here jesus = "" mango = [] for i in args: if i in mango: continue

twoSum

NodeJS
1 year ago
function twoSum(numbers, target) { for (var i = 0; i < numbers.length-1; i++) { for (var j = i+1; j < numbers.length; j++) { if (numbers[i] + numbers[j] === target) console.log(i, j); } } } twoSum([1, 2, 3], 4)

Count the divisors of a number

NodeJS
1 year ago
function getDivisorsCnt(n){ var num=0; if(n==1) return 1; if(n%Math.sqrt(n)==0) num++; for(var i=1;i<Math.sqrt(n);i++){ if(n%i==0){ num+=2; } } return num;

Who likes it?

NodeJS
1 year ago
/* * You probably know the "like" system from Facebook and other pages. * People can "like" blog posts, pictures or other items. * We want to create the text that should be displayed next to such an item. * * Implement the function which takes an array containing the names of people that like an item. * It must return the display text as shown in the examples: * * [] --> "no one likes this" * ["Peter"] --> "Peter likes this"

I love you, a little , a lot, passionately ... not at all

NodeJS
1 year ago
function howMuchILoveYou(nbPetals) { let phrase = { 0: "not at all", 1: "I love you", 2: "a little", 3: "a lot", 4: "passionately", 5: "madly" } return phrase[nbPetals%6]

case

NodeJS
1 year ago
function basicOp(operation, value1, value2) { var cases = { '+': value1 + value2, '-': value1 - value2, '*': value1 * value2, '/': value1 / value2 }; return cases[operation] }

Basic Mathematical Operations

NodeJS
1 year ago
// function basicOp(operation, value1, value2){ // return eval(`${value1} ${operation} ${value2}`); // } // Para convertir un string en parte del código JavaScript y ejecutarlo, puedes usar la función `eval()`. Sin embargo, es importante tener en cuenta que el uso de `eval()` puede ser peligroso si no se maneja con cuidado, ya que permite la ejecución de código arbitrario y puede abrir la puerta a vulnerabilidades de seguridad, como la ejecución de código malicioso.

Find the odd int

NodeJS
1 year ago
// Given an array of integers, find the one that appears an odd number of times. // There will always be only one integer that appears an odd number of times. // Examples // [7] should return 7, because it occurs 1 time (which is odd). // [0] should return 0, because it occurs 1 time (which is odd). // [1,1,2] should return 2, because it occurs 1 time (which is odd). // [0,1,0,1,0] should return 0, because it occurs 3 times (which is odd). // [1,2,2,3,3,3,4,3,3,3,2,2,1] should return 4, becau

Your order, please

NodeJS
1 year ago
// DESCRIPTION: // Your task is to sort a given string. Each word in the string will contain a single number. This number is the position the word should have in the result. // Note: Numbers can be from 1 to 9. So 1 will be the first word (not 0). // If the input string is empty, return an empty string. The words in the input String will only contain valid consecutive numbers. // Examples // "is2 Thi1s T4est 3a" --> "Thi1s is2 3a T4est" // "4of Fo1r pe6ople g3ood th5e the2" --> "Fo1r the

Estudiar

NodeJS
2 years ago
function pickPeaks(arr) { let pos = []; let peaks = []; for (let i = 1; i < arr.length - 1; i++) { if (arr[i] > arr[i - 1] && arr[i] > arr[i + 1]) { pos.push(i); peaks.push(arr[i]); } else if (arr[i] > arr[i - 1] && arr[i] === arr[i + 1]) { let plateauStart = i;

Estudiar forEach

NodeJS
2 years ago
function duplicateCount(text){ var lower = text.toLowerCase(); var count = 0; var used = []; lower.split('').forEach( function(letter) {if (!used.includes(letter) && (lower.split(letter).length - 1) > 1) {count++; used.push(letter);}}); // console.log(used); console.log(count);

Ejemplos de propytas array

NodeJS
2 years ago
//primera parte function duplicateCount(text){ var textArray = text.split(''); // console.log(textArray); // const numberText = textArray.find((element) => element === "l"); // console.log(numberText); }

coodern Best options

NodeJS
2 years ago
function isValidWalk(walk) { // //insert brilliant code here console.log(walk); // see the data console.log(walk.length) const sumN = (walk.filter((walkD) => walkD === 'n')).length // 1 const sumS = (walk.filter((walkD) => walkD === 's')).length const sumW = (walk.filter((walkD) => walkD === 'w')).length const sumE = (walk.filter((walkD) => walkD === 'e')).length

Example test array

NodeJS
2 years ago
function isValidWalk(walk) { console.log(walk); var coorden = ['n', 's', 'e', 'w'] // (walk.filter((walkD) => walkD === 'n')).length function COO(params) {

Learn JavaScript - Full Course for Beginners - Array

NodeJS
2 years ago
// Manipulate Arrays with pop() var ourArray = [1, 2, 3]; var removedFromOurArray = ourArray.pop(); console.log(removedFromOurArray) // Setup

Learn JavaScript - Full Course for Beginners

NodeJS
2 years ago
// // Setup // var lastName = "LoveLace"; // var lastLetterOfLastName = lastName[lastName.length - 1]; // console.log(lastLetterOfLastName); // // blocks // function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {