Snippets Collections
db.participantDietMealPlanDetails.updateMany({
    "mealPlan.dishVariation": "Milkshake",
	"_id":ObjectId("60d4258c4adb9a4b6fe4d99b")
},
    {
    $set: {
        "mealPlan.$[elem].dishVariation": "Milkshake",
        "mealPlan.$[elem].dishVariationId":  "660ea659e1645e032a289770",
        "mealPlan.$[elem].sizes": [{
                "calories": {
                    "value": "184",
                    "unit": "kcal"
                },
                "cookedWeight": "200",
                "name": "Medium Glass",
                "fat": {
                    "value": "5.0",
                    "unit": "gms"
                },
                "calcium": {
                    "value": "0.0",
                    "unit": "mg"
                },
                "iron": {
                    "value": "0.0",
                    "unit": "mg"
                },
                "fibre": {
                    "value": "0.0",
                    "unit": "mg"
                },
                "sodium": {
                    "value": "0.0",
                    "unit": "mg"
                },
                "sugars": {
                    "value": "0.0",
                    "unit": "mg"
                },
                "protein": {
                    "value": "4.7",
                    "unit": "gms"
                },
                "carbs": {
                    "value": "30.4",
                    "unit": "gms"
                }
            }
        ]

    }
}, {
    arrayFilters: [{
            "elem.dishVariation": "Milkshake"
        }
    ]
})
// Assuming you have a model for the table you want to insert into
$model = new YourModel;
$model->packages = json_encode(request('packages')); // Store the selected packages as a JSON array
$model->save();


===================
  $packages = json_decode($model->packages);
 <ul className='rating'>
    {Array.from({ length: 10 }, (_, i) => (
      <li key={`rating-${i + 1}`}>
        <input
          type='radio'
          id={`num${i + 1}`}
          name='rating'
          value={i + 1}
          onChange={handleChange}
          checked={selected === i + 1}
        />
        <label htmlFor={`num${i + 1}`}>{i + 1}</label>
      </li>
    ))}
  </ul>
 const numbersArray = Array.from({length: 20}, ((_, index) => index + 1));
class Solution {
public:
    vector<int> duplicates(vector<int>& nums){
        unordered_set<int> uSet;
        int n = nums.size();
        vector<int> dup(n, 0);
        for(int i = 0 ; i < n ;i++){
            if(uSet.find(nums[i]) != uSet.end()){
                dup[i] = 1;
            }
            if(i != 0)
                dup[i] += dup[i-1];
            uSet.insert(nums[i]);
        }
        return dup;
    }
    int minOperations(vector<int>& nums) {
        sort(nums.begin(), nums.end());
        int req = nums.size() - 1 , ans = nums.size() - 1, n =nums.size();
        vector<int> d = duplicates(nums);
        for(int ptr = 0; ptr < n-1 ;ptr++ ){
            int idx = lower_bound(nums.begin(), nums.end(), req + nums[ptr]) - nums.begin();
            if(idx < n ){
                int val = nums[ptr] + req;
                if(nums[idx] != val)
                    ans = min(ans, n - idx + ptr + d[idx] - d[ptr]);
                else
                    ans = min(ans, n - idx + ptr - 1 + d[idx] - d[ptr]);
            } 
            else
                ans = min(ans, d[n-1] - d[ptr]+ptr);
        }
        return ans;

    }
};
function filterAndCheckValue(array, valueToCheck) {
  const filteredArray = array.filter(item => item === valueToCheck);

  if (filteredArray.length === 0) {
    return array;
  }

  return filteredArray;
}

const myArray = [1, 2, 3, 4, 5];
const valueToFind = 6;

const result = filterAndCheckValue(myArray, valueToFind);
console.log(result); // Output: [1, 2, 3, 4, 5]
const paginate = (array) => {
  const itemsPerPage = 10;
  const numberOfPages = Math.ceil( array.length / itemsPerPage);

  // need to create an array of arrays [[10], [20], [30]] etc
  return Array.from({ length: numberOfPages }, (_, pageIndex) => {
    const startIndex = pageIndex * itemsPerPage;
    return array.slice(startIndex, startIndex + itemsPerPage);
  });

}

export default paginate
#include <bits/stdc++.h>
using namespace std;

void insertion_sort(int arr[] , int n)
{
    for(int i=0;i<=n-1;i++){
        int j = i;
        
        while(j>0, arr[j-1] > arr[j])
        {
            int temp = arr[j-1];
            arr[j-1] = arr[j];
            arr[j] = temp;
            
            j--;
        }
    }
}
int main() {
    
    int n;
    cin>>n;
    int arr[n];
    for(int i=0;i<n;i++){
        cin>>arr[i];
    }
    
    insertion_sort(arr, n);
    for(int i=0;i<n;i++){
        cout<<arr[i]<<" ";
    }
    

    return 0;
}
class Solution{
    public:
    // arr: input array
    // n: size of array
    //Function to rearrange an array so that arr[i] becomes arr[arr[i]]
    //with O(1) extra space.
    void arrange(long long v[], int n) {
        // Your code here
        for(int i= 0; i < n; i++){
            if(v[i] >= 0){
                int val = -v[i], ini = i, p = i;
                while( v[p] != ini){
                    int t = v[p];
                    v[p] = v[t];
        		    if(v[p] == 0)
        			    v[p] = INT_MIN;
        		    else
        			    v[p] *= -1;
            		p = t;
                }
                v[p] = val;
            }
        }
        for(int i= 0; i <n ;i++)
            if(v[i] != INT_MIN)
                v[i] *= -1;
            else
                v[i] = 0;
    }
};
function check(a,x){
  return a.includes(x);
};
function repeatStr (n, s) {
  return s.repeat(n);
}
//Opción 1:
function areYouPlayingBanjo(name) {
  return name + (name[0].toLowerCase() == 'r' ? ' plays' : ' does not play') + " banjo";
}

//Opción 2:
function areYouPlayingBanjo(name) {
  const letra = name.charAt(0);
  if (letra === "r" || letra === "R") {
    return name + " toca el banjo";
  }
  return name + " no toca el banjo";
}
const points=games=>games.reduce((output,current)=>{
    return output += current[0]>current[2] ? 3 : current[0]===current[2] ? 1 : 0;
  },0)

//DIFERENTE ESCRITO:
 function points(games) {
   return games.reduce((output,current)=>{
     let x = parseInt(current[0]);
     let y = parseInt(current[2]);
     let value= x>y ? 3 : x===y ? 1 : 0;
     return output+value;
   },0)
 }
function positiveSum(arr) {
  var total = 0;    
  for (i = 0; i < arr.length; i++) {   
    if (arr[i] > 0) {                   // if arr[i] es mayor a 0
      total += arr[i];                  // dar el total de la suma de esos arr[i]
    }
  }
  return total;                         // return total
}
//Opción 1:
function findAverage(array) {
  if(array.length === 0) {
    return(0);
  }
  return array.reduce((a, b) => a + b, 0) / array.length;
} 

//Opción 2:
var find_average = (array) => {  
  return array.length === 0 ? 0 : array.reduce((a, b)=> a + b, 0)/array.length
}
function findNeedle(haystack) {
  return "found the needle at position " + haystack.indexOf("needle");
}
smash = function (words) {
  return words.join(" ");
};
const parts = ["shoulders", "knees"];

const lyrics = ["head", ...parts, "and", "toes"];

// TOTAL lyrics ["head", "shoulders", "knees", "and", "toes"]
const min = (list) => Math.min(...list);
const max = (list) => Math.max(...list);
//OPCIÓN 1
function getGrade (s1, s2, s3) {
  avg = (s1+s2+s3)/3;
  if (avg < 60)  return "F";
    else if (avg < 70) return "D";
    else if (avg < 80) return "C";
    else if (avg < 90) return "B";
    else return "A";
}

//OPCIÓN 2
function getGrade(...scores) {
  let avg = scores.reduce((a, b) => a + b, 0) / scores.length;
  
  if (avg < 60)  return "F";
    else if (avg < 70) return "D";
    else if (avg < 80) return "C";
    else if (avg < 90) return "B";
    else return "A";
function solution(str){
  return str.split('').reverse().join('');  
}
function removeChar(str){
  return str.slice(1, -1); 
};
const users = [
  { name: "user1", age: 28 },
  { name: "user2", age: 21 },
  { name: "user3", age: 38 },
  { name: "user4", age: 18 }
];

users.sort((user1, user2) => user1.age - user2.age);

console.log(users);
const nestedArray = [1, [2], [[3], 4], 5];

const flatten = nestedArray =>
  nestedArray.reduce(
    (flat, item) => flat.concat(Array.isArray(item) ? flatten(item) : [item]),
    []
  );

flatten(nestedArray);
const friends = [
  { name: "Abby", age: 22 },
  { name: "Boby", age: 16 },
  { name: "Coel", age: 20 },
  { name: "Dany", age: 15 }
];

//who can drink?
friends.filter(friend => friend.age >= 18);
const apps = ["phone", "calculator", "clock"];

apps.length = 0;

console.log(apps);
const apps = ["phone", "calculator", "clock"];
const object = { ...apps };

console.log(object);
const apps = ["phone", "calculator", "clock"];

const clonedApps = [...apps];
const elements = ["Eat", "Sleep", "Code", "Repeat"];

elements.join(",");
const winners = ["Jane", "Bob"];
const losers = ["Ronald", "Kevin"];

const players = [...winners, ...losers];
const apps = ["phone", "calculator", "clock"];

apps.includes("calculator");
const ages = [18, 20, 21, 30];

const agesPlusOne = ages.map(age => age + 1);
const apps = [];

apps.push("calculator");

apps.push("phone", "clock");
import "./styles.css";

const date = new Date();
const root = document.getElementById("app");
root.setAttribute("data-posts", "[]");

const items = [
  {
    title: "book 1",
    author: "David",
  },
  {
    title: "book 2",
    author: "Kevin",
  }
];

const posts = () => {
  setTimeout(() => {
    let outPut = `<ul>`;
    for (let item of items) {
      outPut += `<li>${item.title}</li>`;
    }
    outPut += `</ul>`;
    root.innerHTML = outPut;
  }, 500);
};



const createPost = (post, callback) => {
  const item = {
    title: post.title,
    author: post.author,
  };

  items.push(item); // push the item to the items array
  callback(); //evoke the callback function

// set the posts data attribute to take in all the items
  root.dataset.posts = JSON.stringify(items);
};

console.log(
  createPost({ title: "book 3", author: "Derek"}, posts)
);


//get list of buttons and make sure there are no duplicates

function displayButtons(){
    const companies = products.reduce((total, item) => {
       total.push(item.company)
       total = [...new Set(total)]
       return total
    },['All'])
 
    const buttons = companies.map((item) => {
       return `<button class="company-btn">${item}</button>`
    }).join('')
 
    buttonsContainer.innerHTML = buttons
 
 }


 // or we could do this...
 const someBtns = ['all',...new Set(products.map((product) => product.company)),];  
  console.log(someBtns)
//Use localStorage for that. It's persistent over sessions.

//Writing :
localStorage['myKey'] = 'somestring'; // only strings

//Reading :
var myVar = localStorage['myKey'] || 'defaultValue';

//If you need to store complex structures, you might serialize them in JSON. For example :

//Reading :
var stored = localStorage['myKey'];
if (stored) myVar = JSON.parse(stored);
else myVar = {a:'test', b: [1, 2, 3]};

//Writing :
localStorage['myKey'] = JSON.stringify(myVar);

//Note that you may use more than one key. They'll all be retrieved by all pages on the same domain.

//Unless you want to be compatible with IE7, you have no reason to use the obsolete and small cookies.
const users = ["Sam", "Alex", "Charley"];
users.at(1); //"Alex"
users.at(-2); //"Alex"
const numbers = [1, 2, 3, 4, 5, 7, 3, 2, 2, 5];
const updated = [...new Set(numbers)]; // result [1, 2, 3, 4, 5, 7]
const getMousePosition = (x, y) => ({
  x: x,
  y: y
});

//can be written as
const getMousePosition = (x, y) => ({ x, y });
const profileUpdate = (profileData) => {
  const { name, age, nationality, location } = profileData;

}
//This effectively destructures the object sent into the function. This can also be done in-place:

const profileUpdate = ({ name, age, nationality, location }) => {

}
//When profileData is passed to the above function, the values are destructured from the function parameter for use within the function.
const persons = [
  {firstname : "Malcom", lastname: "Reynolds"},
  {firstname : "Kaylee", lastname: "Frye"},
  {firstname : "Jayne", lastname: "Cobb"}
];

persons.map(getFullName);

function getFullName(item) {
  return [item.firstname,item.lastname].join(" ");
}
function quickSort(arr) {
  if (arr.length <= 1) {
    return arr;
  }
  const Pivot = arr[arr.length - 1];
  const LeftSide = [];
  const RightSide = [];
  for (let index = 0; index < arr.length - 1; index++) {
    if (arr[index] < Pivot) {
      LeftSide.push(arr[index]);
    } else {
      RightSide.push(arr[index]);
    }
  }
  return [...quickSort(LeftSide), Pivot, ...quickSort(RightSide)];
}
const a = quickSort([1, 2, 5, 7, 3, 0.99, -199, -1, 99]);

a; // [ -199, -1, 0.99, 1, 2, 3, 5, 7, 99 ]

const removeArrDup = (arr = []) => [... new Set(arr)]

removeArrDup([1,1,2,2,2,3])
// Expect output to be  [1,2,3]
haystack.indexOf(haystack.find(arr => arr.includes(search)));
<- 2
        let dataToUpdate = [
            "certificationsList" : FieldValue.arrayUnion (
                [[ "company": certificate.company,
                   "title" : certificate.title,
                   "startDate" : startDate1,
                   "endDate" : endDate1
                ]])
              ]
        let dataToUpdate = [
            "languagesList" : FieldValue.arrayUnion(
                [[ "languageLevel": language.language_Level,
                "languageTitle" : language.language_Title  ]])
                                                    ]
// Supported in IE 9-11
const people = [
  {id: 1, name: 'John'},
  {id: 2, name: 'Adam'},
];

const isFound = people.some(element => {
  if (element.id === 1) {
    return true;
  }

  return false;
});

console.log(isFound); // 👉️ true

if (isFound) {
  // object is contained in array
}
using System;

namespace MultiDArray {
  class Program {
    static void Main(string[] args) {
           
        //initializing 2D array
       int[ , ] numbers = {{2, 3}, {4, 5}};
 	 
        // access first element from the first row
       Console.WriteLine("Element at index [0, 0] : "+numbers[0, 0]);
  	 
        // access first element from second row
       Console.WriteLine("Element at index [1, 0] : "+numbers[1, 0]);
    }
  }
}
const refunds = [
  {
    request_amount_to_refund: "3000",
    entity_id: "1850231228424",
    is_zni: false
  },
  {
    request_amount_to_refund: "2000",
    entity_id: "1850231228422",
    is_zni: false
  },
  {
    request_amount_to_refund: "1000",
    entity_id: "1850231228422",
    is_zni: true
  },
  {
    request_amount_to_refund: "500",
    entity_id: "1850231228422",
    is_zni: true
  }
]
    
const refundsFormatted = Object.values(refunds.reduce((acc, curr) => {
  const valueId = `${curr.entity_id}-${curr.is_zni}`

  // Does value already exist ?
  const existingValue = acc[valueId]

  // Values to add
  const existingRequestAmount = parseInt(existingValue?.request_amount_to_refund ?? 0)
  const newRequestAmount = parseInt(curr?.request_amount_to_refund ?? 0)
  const quantity = existingValue?.quantity ? existingValue?.quantity + 1 : 1

  const newValue = {
    ...curr,
    request_amount_to_refund: existingRequestAmount + newRequestAmount,
    quantity: quantity
  }
  return ({
    ...acc,
    [valueId]: newValue,
  })
}, {}))

console.log(refundsFormatted)

/**
Output expected 

[
  {
    request_amount_to_refund: "3000",
    entity_id: "1850231228424",
    is_zni: false,
    quantity: 1
  },
  {
    request_amount_to_refund: "2000",
    entity_id: "1850231228422",
    is_zni: false,
    quantity: 1
  },
  {
    request_amount_to_refund: "1500",
    entity_id: "1850231228422",
    is_zni: true,
    quantity: 2
  }
]
*/
class Solution 
{
    //Function to find minimum number of operations that are required 
    //to make the matrix beautiful.
    static int findMinOperation(int matrix[][], int n)
    {
        int sumRow[] = new int[n];
        int sumCol[] = new int[n];
        Arrays.fill(sumRow, 0);
        Arrays.fill(sumCol, 0);
        
        //calculating sumRow[] and sumCol[] array.
        for(int i = 0; i < n; i++)
        {
            for(int j = 0; j < n; j++)
            {
                sumRow[i] += matrix[i][j];
                sumCol[j] += matrix[i][j];
                  
            }
        }
        
        //finding maximum sum value in either row or in column.
        int maxSum = 0;
        for (int i = 0; i < n; ++i)
        {
            maxSum = Math.max(maxSum, sumRow[i]);
            maxSum = Math.max(maxSum, sumCol[i]);
        } 
        
        int count = 0;
        for (int i = 0, j = 0; i < n && j < n;) 
        {
            //finding minimum increment required in either row or column.
            int diff = Math.min(maxSum - sumRow[i], maxSum - sumCol[j]);
            
            //adding difference in corresponding cell, 
            //sumRow[] and sumCol[] array.
            matrix[i][j] += diff;
            sumRow[i] += diff;
            sumCol[j] += diff;
            
            //updating the result.
            count += diff;
            
            //if ith row is satisfied, incrementing i for next iteration.
            if (sumRow[i] == maxSum)
                ++i;
            
            //if jth column is satisfied, incrementing j for next iteration.
            if (sumCol[j] == maxSum)
                ++j;
        }
        //returning the result.
        return count;
    }
}
class Solution
{
    //Function to modify the matrix such that if a matrix cell matrix[i][j]
    //is 1 then all the cells in its ith row and jth column will become 1.
    void booleanMatrix(int matrix[][])
    {
        int r = matrix.length;
        int c = matrix[0].length;

        //using two list to keep track of the rows and columns 
        //that needs to be updated with 1.
        int row[] = new int[r];
        int col[] = new int[c];
        
        for(int i = 0; i < r; i++)
        {
            for(int j = 0; j < c; j++)
            {
                //if we get 1 in matrix, we mark ith row and jth column as 1.
                if(matrix[i][j] == 1){
                    row[i] = 1;
                    col[j] = 1;
                }  
            }
        }
        
        for(int i =0; i < r; i++)
        {
            for(int j = 0; j < c; j++)
            {
                //if ith row or jth column is marked as 1, then all elements
                //of matrix in that row and column will be 1.
                if(row[i] == 1 || col[j] == 1){
                    matrix[i][j] = 1;
                }
            }
        }
    }
}
class Solution
{
    //Function to interchange the rows of a matrix.
    static void interchangeRows(int matrix[][])
    {
       for(int i=0;i<matrix.length/2;i++){
           for(int j=0;j<matrix[i].length;j++){
               int temp=matrix[i][j];
               matrix[i][j]=matrix[matrix.length-i-1][j];
               matrix[matrix.length-i-1][j]=temp;
           }
       } 
    }
}
class Solution
{
    //Function to reverse the columns of a matrix.
    static void reverseCol(int matrix[][])
    {
       for(int i=0; i<matrix.length; i++){
           for(int j=0; j<matrix[i].length/2; j++)
           {
               int temp = matrix[i][j];
               matrix[i][j] = matrix[i][matrix[i].length-j-1];
               matrix[i][matrix[i].length-j-1] = temp;
           }
       } 
    }
}
class Solution
{
    //Function to exchange first column of a matrix with its last column.
    static void exchangeColumns(int matrix[][])
    {
       int temp = 0;
       for (int i=0; i<matrix.length; i++)
       {
            temp = matrix[i][0];
            matrix[i][0] = matrix[i][matrix[i].length-1];
            matrix[i][matrix[i].length-1] = temp; 
       }
    }
}
class Solution
{
    //Function to get cofactor of matrix[p][q] in temp[][]. 
    static void getCofactor(int matrix[][], int temp[][], int p, int q, int n)
    {
        int i = 0, j = 0;

        for (int row = 0; row < n; row++)
        {
            for (int col = 0; col < n; col++)
            {
                //copying only those elements into temporary matrix 
                //which are not in given row and column.
                if(row != p && col != q)
                {
                    temp[i][j++] = matrix[row][col];

                    //if row is filled, we increase row index and
                    //reset column index.
                    if(j == n - 1)
                    {
                        j = 0;
                        i++;
                    }
                }
            }
         }
    }
    
    
    //Function for finding determinant of matrix.
    static int determinantOfMatrix(int matrix[][], int n)
    {
        int D = 0; 

        //base case
        if (n == 1)
            return matrix[0][0];

        //creating a list to store Cofactors.
        int temp[][]  = new int[n][n];

        int sign = 1;

        //iterating for each element of first row.
        for (int i = 0; i < n; i++)
        {
            //getting Cofactor of matrix[0][i].
            getCofactor(matrix, temp, 0, i, n);
            D += sign * matrix[0][i] * determinantOfMatrix(temp, n - 1);

            //terms are to be added with alternate sign so changing the sign.
            sign = -sign;
        }
        //returning the determinant.
        return D;
    }
}
class Solution
{
    //Function to multiply two matrices.
    static int[][] multiplyMatrix(int A[][], int B[][])
    {
        int n1 = a.length;
        int m1 = a[0].length;
        int n2 = b.length;
        int m2 = b[0].length;
        
        if(m1!=n2)
        {
            int arr0[][] = new int[1][1];
            arr0[0][0] = -1;
            return arr0;
        }
        
        int arr[][] = new int[n1][m2];
        
        for(int i = 0 ; i<n1 ; i++)
        for(int j = 0 ; j<m2 ; j++)
        for(int q = 0; q<n2 ; q++)
        arr[i][j]+= a[i][q]*b[q][j];
        
        return arr;
    }
}
class Solution
{
    //Function to return sum of upper and lower triangles of a matrix.
    static ArrayList<Integer> sumTriangles(int matrix[][], int n)
    {
        ArrayList<Integer> list=new ArrayList<>();
        int sum1=0;
        int sum2=0;
        for(int g=0; g<matrix.length; g++){
            for(int i=0, j=g; j<matrix.length; i++,j++){
                sum1+=matrix[i][j];
            }
        }
        list.add(sum1);
        for(int g=0; g<matrix.length; g++){
            for(int i=g,j=0; i<matrix.length; i++,j++){
                sum2+=matrix[i][j];
            }
        }
        list.add(sum2);
        return list;
    }
}
class Solution
{
    //Function to add two matrices.
    static int[][] sumMatrix(int A[][], int B[][])
    {
        int n = A.length, m = A[0].length;
        int res[][] = new int[0][0];
        //Check if two input matrix are of different dimensions
        if(n != B.length || m != B[0].length)
            return res;
        
        res = new int[n][m];
        for(int i=0;i<n;i++)
            for(int j=0;j<m;j++)
                res[i][j] = A[i][j] + B[i][j];
                
        return res;
    }
}
// Time Complexity : O(r * log(max - min) * logC)

import java.util.Arrays;

public class MedianInRowSorted
{
    static public int matMed(int mat[][], int r ,int c)
    {
    	int min = mat[0][0], max = mat[0][c-1];
    	for (int i=1; i<r; i++)
    	{
    		if (mat[i][0] < min)
    			min = mat[i][0];
    
    		if (mat[i][c-1] > max)
    			max = mat[i][c-1];
    	}
    
    	int medPos = (r * c + 1) / 2;
    	while (min < max)
    	{
    		int mid = (min + max) / 2;
    		int midPos = 0;
            int pos = 0;
    		for (int i = 0; i < r; ++i){
    			    pos = Arrays.binarySearch(mat[i],mid);
                    
                    if(pos < 0)
                        pos = Math.abs(pos) - 1;
                      
                    
                    else
                    {
                        while(pos < mat[i].length && mat[i][pos] == mid)
                            pos += 1;
                    }
                      
                    midPos = midPos + pos;
    		}
    		if (midPos < medPos)
    			min = mid + 1;
    		else
    			max = mid;
    	}
    	return min;
    }

    public static void main(String[] args)
    {
    	int r = 3, c = 5;
    	int m[][]= { {5,10,20,30,40}, {1,2,3,4,6}, {11,13,15,17,19} };
    	System.out.println("Median is " + matMed(m, r, c)); 
    	
    }
}
// Efficient Code : Time Complexity : O(R + C)
 
import java.util.*;
import java.io.*;
 
class GFG 
{ 
	static int R = 4, C = 4;

	static void search(int mat[][], int x)
	{
		int i  = 0, j = C - 1;

		while(i < R && j >= 0)
		{
			if(mat[i][j] == x)
			{
				System.out.println("Found at (" + i + ", " + j + ")");
				return;
			}
			else if(mat[i][j] > x)
			{
				j--;
			}
			else
			{
				i++;
			}
		}
		System.out.println("Not Found");
	}

	public static void main(String args[]) 
    {
        int arr[][] = {{10, 20, 30, 40},
    				   {15, 25, 35, 45},
    				   {27, 29, 35, 45},
    				   {32, 33, 39, 50}};
    	int x = 29;	   

    	search(arr, x);

		
    } 
}
 
 
 
 
// Naive Code : Time Complexity : O(R * C)
 
	static int R = 4, C = 4;

	static void search(int mat[][], int x)
	{
		for(int i = 0; i < R; i++)
		{
			for(int j = 0; j < C; j++)
			{
				if(mat[i][j] == x)
				{
					System.out.println("Found at (" + i + ", " + j + ")");
					
					return;
				}
			}
		}

		System.out.println("Not Found");
	}
import java.util.*;
import java.io.*;

class GFG 
{ 
	static void printSpiral(int mat[][], int R, int C)
	{
		int top = 0, left = 0, bottom = R - 1, right = C - 1;

		while(top <= bottom && left <= right)
		{
			for(int i = left; i <= right; i++)
				System.out.print(mat[top][i] + " ");

			top++;

			for(int i = top; i <= bottom; i++)
				System.out.print(mat[i][right] + " ");
			
			right--;

			if(top <= bottom){
			for(int i = right; i >= left; i--)
				System.out.print(mat[bottom][i] + " ");

			bottom--;
			}

			if(left <= right){
			for(int i = bottom; i >= top; i--)
				System.out.print(mat[i][left] + " ");

			left++;
			}			
		}
	}

	public static void main(String args[]) 
    {
        int arr[][] = {{1, 2, 3, 4},
    				   {5, 6, 7, 8},
    				   {9, 10, 11, 12},
    				   {13, 14, 15, 16}};

    	printSpiral(arr, 4, 4);
    } 
}
// Efficient Code : Time Complexity : O(n^2), Auxiliary Space : O(1)
 
import java.util.*;
import java.io.*;
 
class GFG 
{ 
	static int n = 4;

	static void swap(int mat[][], int i, int j)
	{
			int temp = mat[i][j];
			mat[i][j] = mat[j][i];
			mat[j][i] = temp;
	}
	
	static void swap2(int low, int high, int i, int mat[][])
	{
	    	int temp = mat[low][i];
			mat[low][i] = mat[high][i];
			mat[high][i] = temp;
	}

	static void rotate90(int mat[][])
	{
		// Transpose
		for(int i = 0; i < n; i++)
			for(int j = i + 1; j < n; j++)
				swap(mat, i, j);
      
		// Reverse columns		
		for(int i = 0; i < n; i++)
		{
		    int low = 0, high = n - 1;
		    
		    while(low < high)
		    {
		        swap2(low, high, i, mat);
		        
		        low++;
		        high--;
		    }
		}
	}

	public static void main(String args[]) 
    {
        int arr[][] = {{1, 2, 3, 4},
    				   {5, 6, 7, 8},
    				   {9, 10, 11, 12},
    				   {13, 14, 15, 16}};

    	rotate90(arr);

    		for(int i = 0; i < n; i++)
			{
				for(int j = 0; j < n; j++)
				{
					System.out.print(arr[i][j]+" ");
				}

				System.out.println();
			}	
    }
}
 
 
 
 
// Naive Code : Time Complexity : O(n^2), Space Complexity : O(n^2)
 
	static int n = 4;

	static void rotate90(int mat[][])
	{
		int temp[][] = new int[n][n];

		for(int i = 0; i < n; i++)
			for(int j = 0; j < n; j++)
				temp[n - j - 1][i] = mat[i][j];

		for(int i = 0; i < n; i++)
			for(int j = 0; j < n; j++)
				mat[i][j] = temp[i][j];

	}

// last column becomes first row
// second last column becomes second row
// Efficient Code : Without Using Auxiliary Array

import java.util.*;
import java.io.*;

class GFG 
{ 
	static int n = 4;

	static void swap(int mat[][], int i, int j)
	{
			int temp = mat[i][j];
			mat[i][j] = mat[j][i];
			mat[j][i] = temp;
	}

	static void transpose(int mat[][])
	{

		for(int i = 0; i < n; i++)
			for(int j = i + 1; j < n; j++)
				swap(mat, i, j);
	}

	public static void main(String args[]) 
    {
        int arr[][] = {{1, 2, 3, 4},
    				   {5, 6, 7, 8},
    				   {9, 10, 11, 12},
    				   {13, 14, 15, 16}};

    	transpose(arr);

    		for(int i = 0; i < n; i++)
			{
				for(int j = 0; j < n; j++)
				{
					System.out.print(arr[i][j]+" ");
				}

				System.out.println();
			}	
    } 
}




// Naive Code : 

	static int n = 4;

	static void transpose(int mat[][])
	{
		int temp[][] = new int[n][n];

		for(int i = 0; i < n; i++)
			for(int j = 0; j < n; j++)
              	// copy
				temp[i][j] = mat[j][i]; // temp[i][j] = mat[i][j];

		for(int i = 0; i < n; i++)
			for(int j = 0; j < n; j++)
              	// copy back to original array
				mat[i][j] = temp[i][j];

	}
import java.util.*;
import java.io.*;

class GFG 
{ 
	static int R = 4, C = 4;

	static void bTraversal(int mat[][])
	{
		if(R == 1)
		{
			for(int i = 0; i < C; i++)
				System.out.print(mat[0][i] + " ");
		}
		else if(C == 1)
		{
			for(int i = 0; i < R; i++)
				System.out.print(mat[i][0] + " ");
		}
		else
		{
			for(int i = 0; i < C; i++)
				System.out.print(mat[0][i] + " ");
			for(int i = 1; i < R; i++)
				System.out.print(mat[i][C - 1] + " ");
			for(int i = C - 2; i >= 0; i--)
				System.out.print(mat[R - 1][i] + " ");
			for(int i = R - 2; i >= 1; i--)
				System.out.print(mat[i][0] + " ");
		}
	}

	public static void main(String args[]) 
    {
        int arr[][] = {{1, 2, 3, 4},
    				   {5, 6, 7, 8},
    				   {9, 10, 11, 12},
    				   {13, 14, 15, 16}};

    	bTraversal(arr);
    } 
}
import java.util.*;
import java.io.*;

class GFG 
{ 
	static int R = 4, C = 4;
	static void printSnake(int mat[][])
	{
		for(int i = 0; i < R; i++)
		{
			if(i % 2 == 0)
			{
				for(int j = 0; j < C; j++)
					System.out.print(mat[i][j] + " ");
			}
			else
			{
				for(int j = C - 1; j >= 0; j--)
					System.out.print(mat[i][j] + " ");
			}
		}
	}

	public static void main(String args[]) 
    {
        int arr[][] = {{1, 2, 3, 4},
    				   {5, 6, 7, 8},
    				   {9, 10, 11, 12},
    				   {13, 14, 15, 16}};

    	printSnake(arr);
    } 
}
self.postModel = self.postModel.sorted(by: { $0.time_stamp > $1.time_stamp
JavaScript

for (let i=0; i < arrayName.length; i++){
  console.log(arrayName[i])
}

i.e.):

movies = ['legally blonde', 'Ms. & Ms. Smith', 'The Incredibles'];

for (let i=0; i < movies.length; i++){
  console.log(movies[i])
}

Python

for singular_array_name in array_name_pluralized:
	print(singular_array_name)

i.e.):

movies = ['legally blonde', 'Ms. & Ms. Smith', 'The Incredibles']

for movie in movies:
	print(movie)
To Filter Model Array:

var filteredItems = unfilteredItems.filter { $0.cat == "garden" }

Arrange :

self.chatModelArray = self.chatModelArray.sorted { $0.time == $1.time }

To Filter name : 

var filteredItems = unfilteredItems.filter { $0.name.localizedCaseInsensitiveContains(textField.text ?? "") }

To Filter an Array:

let result = arr.filter {$0.contains("ali")}
// Array Remove - By John Resig (MIT Licensed)
Array.prototype.remove = function(from, to) {
  var rest = this.slice((to || from) + 1 || this.length);
  this.length = from < 0 ? this.length + from : from;
  return this.push.apply(this, rest);
};
let secretMessage = ['Learning', 'is', 'not', 'about', 'what', 'you', 'get', 'easily', 'the', 'first', 'time,', 'it', 'is', 'about', 'what', 'you', 'can', 'figure', 'out.', '-2015,', 'Chris', 'Pine,', 'Learn', 'JavaScript'];

secretMessage.pop();

// console.log(secretMessage.length);

secretMessage.push('to', 'Program.');

secretMessage[7] = 'right';

// console.log(secretMessage);

secretMessage.shift();

secretMessage.unshift('Programming');

secretMessage.splice(6, 5, 'know');

// console.log(secretMessage);

console.log(secretMessage.join(' '));
array_multisort(array_map(function($element) {
  return $element['key'];
}, $result), SORT_ASC, $result);
const arr = [1, 2, 3, 4];

// bad
const first = arr[0];
const second = arr[1];

// good
const [first, second] = arr;
cars.some(car => car.color === "red" && car.type === "cabrio");
// output: true

cars.every(car => car.capacity >= 4);
// output: false
let sortedCars = cars.sort((c1, c2) => (c1.capacity < c2.capacity) ? 1 : (c1.capacity > c2.capacity) ? -1 : 0);
console.log(sortedCars);
// output:
// [
//   {
//     color: 'purple',
//     type: 'minivan',
//     registration: 'Wed Feb 01 2017 00:00:00 GMT+0100 (GMT+01:00)',
//     capacity: 7
//   },
//   {
//     color: 'red',
//     type: 'station wagon',
//     registration: 'Sat Mar 03 2018 01:00:00 GMT+0100 (GMT+01:00)',
//     capacity: 5
//   },
//   ...
// ]
cars.forEach(car => {
 car['size'] = "large";
 if (car.capacity <= 5){
   car['size'] = "medium";
 }
 if (car.capacity <= 3){
   car['size'] = "small";
 }
});
cars.forEach(car => {
 car['size'] = "large";
 if (car.capacity <= 5){
   car['size'] = "medium";
 }
 if (car.capacity <= 3){
   car['size'] = "small";
 }
});
let sizes = cars.map(car => {
  if (car.capacity <= 3){
    return "small";
  }
  if (car.capacity <= 5){
    return "medium";
  }
  return "large";
});
console.log(sizes);
// output:
// ['large','medium','medium', ..., 'small']

//create a new object if we need more values:

let carsProperties = cars.map(car => {
 let properties = {
   "capacity": car.capacity,
   "size": "large"
 };
 if (car.capacity <= 5){
   properties['size'] = "medium";
 }
 if (car.capacity <= 3){
   properties['size'] = "small";
 }
 return properties;
});
console.log(carsProperties);
// output:
// [
//   { capacity: 7, size: 'large' },
//   { capacity: 5, size: 'medium' },
//   { capacity: 5, size: 'medium' },
//   { capacity: 2, size: 'small' },
//   ...
// ]
import React from 'react';

const people = [
  {
    name: 'James',
    age: 31,
  },
  {
    name: 'John',
    age: 45,
  },
  {
    name: 'Paul',
    age: 65,
  },
  {
    name: 'Ringo',
    age: 49,
  },
  {
    name: 'George',
    age: 34,
  }
];

function App() {
  return (
    <div>
      {people.filter(person => person.age < 60).map(filteredPerson => (
        <li>
          {filteredPerson.name}
        </li>
      ))}
    </div>
  );
}

export default App;
import React from 'react';

const names = ['James', 'John', 'Paul', 'Ringo', 'George'];

function App() {
  return (
    <div>
      {names.filter(name => name.includes('J')).map(filteredName => (
        <li>
          {filteredName}
        </li>
      ))}
    </div>
  );
}

export default App;
// This is what I've been using, pretty straight forward
// It passes the JSON to the children as props
// Of course, you fetch what you will
 
import React, { Component, Fragment } from 'react';
 
export class FetchJsonController extends Component
{
	constructor(props) {
		super(props);
		this.state = {
			data: null,
		};
	}
 
	componentDidMount() {
		fetch(this.props.src)
			.then(response => response.json())
			.then(data => {
				console.log(data);
				this.setState({ data })
			});
	}
 
	render() {
		const _data = this.state.data;
		const children = React.Children.map(this.props.children, child => {
			return React.cloneElement(child, {
				jsonData: _data
			});
		});
		return (
			<div>{ children }</div>
		)
	}
}
 
// This is how it's used
// SomeCompnent will receive the JSON data
<FetchJsonController src="somefile.json">
  <SomeComponent />
</FetchJsonController>
//What are pure functions?
//Pure functions take an input value (a parameter or argument) and produce an output value. //Like with hashing, the same input it will always return the same output 

const myPureFunction = number => return number * 4

//Pure functions must:
//1. Contain no side effects
//2. When given the same input, return the same output.
// A pure component avoids any use of state.
map
filter
reduce
import React, { Component } from "react";

class IconList extends Component {
  static defaultProps = {
    options: [
      "angry",
      "anchor",
      "archive",
      "at",
      "archway",
      "baby",
      "bell",
      "bolt",
      "bone",
      "car",
      "city",
      "cloud",
      "couch"
    ]
  };
  constructor(props) {
    super(props);
    this.state = { icons: ["bone", "cloud"] };
    this.addIcon = this.addIcon.bind(this);
  }
  //DON'T DO THIS!!!!
  // addIcon() {
  //   let idx = Math.floor(Math.random() * this.props.options.length);
  //   let newIcon = this.props.options[idx];
  //   let icons = this.state.icons;
  //   icons.push(newIcon);
  //   this.setState({ icons: icons });
  // }

  addIcon() {
    // get random index
    let idx = Math.floor(Math.random() * this.props.options.length);
 	// get new element
    let newIcon = this.props.options[idx];
    // update the state of the icons array (spread icons into new array, add new icon to it)
    this.setState({ icons: [...this.state.icons, newIcon] });
  }
  render() {
    // render newly mapped icons array
    const icons = this.state.icons.map(i => <i className={`fas fa-${i}`} />);
    return (
      <div>
        <h1>Icons: {icons}</h1>
        <button onClick={this.addIcon}>Add New Icon</button>
      </div>
    );
  }
}

export default IconList;
<?php
$url = "https://graph.instagram.com/me/media?access_token=IGQVJWVGM5azZApYkEwTENxQ19kbWdmS1dfeWxJcUk2VzJobF92LWE5NTdsNlV0dGFoNGw2bkRMZATh2SnFzcGVOeDJXNVNzcUoyS3pOY2taZA3BfX25sUHA3VXVHUlBTNFVGVHp1aEktOUxXbDlpV3cxeAZDZD&fields=media_url,media_type,caption,permalink";
// create curl resource
$ch = curl_init();

// set url
curl_setopt($ch, CURLOPT_URL, $url);

//return the transfer as a string
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

// $output contains the output string
$instagramData = curl_exec($ch);
// close curl resource to free up system resources
curl_close($ch); 

$instagramData = json_decode($instagramData, true); // true = to array έστω
$instagramData = $instagramData['data'];

$tpl = 'instagramFeedTPL';
$out = '';

foreach ($instagramData as $data)
{
    if ($data['media_type'] == 'VIDEO')
    {
        $data['isVideo'] = 1;
    }
    
    $out .= $modx->getChunk($tpl, $data);
}


return $out;
function randomEl(array) {
	const idx = Math.floor(Math.random() * array.length);
	return array[idx];
}
function removeAllItems(arr, value) {
  var i = 0;
  while (i < arr.length) {
    if (arr[i] === value) {
      arr.splice(i, 1);
    } else {
      ++i;
    }
  }
  return arr;
}

console.log(removeAllItems([2,5,9,1,5,8,5], 5))
function remove(array, el) {
	const index = array.indexOf(el);
	if (index > -1) {
		const foundEl = array.splice(index, 1);
        return foundEl;
	}
    return undefined;
}
console.log(remove([2,5,9,1,5,8,5], 5))
Example: Shuffle Deck of Cards

// program to shuffle the deck of cards

// declare card elements
const suits = ["Spades", "Diamonds", "Club", "Heart"];
const values = [
  "Ace",
  "2",
  "3",
  "4",
  "5",
  "6",
  "7",
  "8",
  "9",
  "10",
  "Jack",
  "Queen",
  "King",
];

// empty array to contain cards
let deck = [];

// create a deck of cards
for (let i = 0; i < suits.length; i++) {
    for (let x = 0; x < values.length; x++) {
        let card = { Value: values[x], Suit: suits[i] };
        deck.push(card);
    }
}

// shuffle the cards
for (let i = deck.length - 1; i > 0; i--) {
    let j = Math.floor(Math.random() * i);
    let temp = deck[i];
    deck[i] = deck[j];
    deck[j] = temp;
}

console.log('The first five cards are:');

// display 5 results
for (let i = 0; i < 5; i++) {
    console.log(`${deck[i].Value} of ${deck[i].Suit}`)
}

//output
The first five cards are:
4 of Club
5 of Diamonds
Jack of Diamonds
2 of Club
4 of Spades
function shuffle(array) {
  const curIdx = array.length;

  // While there remain elements to shuffle...
  while (0 !== cur_idx) {
    // Pick a remaining element...
    const randIdx = Math.floor(Math.random() * curIdx);
    curIdx -= 1;

    // And swap it with the current element.
    const originalIdx = array[curIdx];
    array[curIdx] = array[randIdx];
    array[randIdx] = originalIdx;
  }
  return array;
}

// Usage of shuffle
const arr = [1, 2, 3, 4, 5, 6];
arr = shuffle(arr);
console.log(arr);

// shorter
function shuffle(array) {
    for (let i = array.length - 1; i > 0; i--) {
        var j = Math.floor(Math.random() * (i + 1));
        var originalIdx = array[i];
        array[i] = array[j];
        array[j] = originalIdx;
    }
}

//es6
function shuffle_array(array) {
    for (let i = array.length - 1; i > 0; i--) {
        const j = Math.floor(Math.random() * (i + 1));
        [array[i], array[j]] = [array[j], array[i]];
    }
}
const shuffleArray = array => {
  for (let i = array.length - 1; i > 0; i--) {
    const j = Math.floor(Math.random() * (i + 1));
    const temp = array[i];
    array[i] = array[j];
    array[j] = temp;
  }
}
const array = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
const shuffledArray = array.sort((a, b) => 0.5 - Math.random());

// using Array map and Math.random
const shuffledArr = array => array.map(a => ({ sort: Math.random(), value: a })).sort((a, b) => a.sort - b.sort).map(a => a.value);

let clickMe = document.querySelector('button');

function getRandomNumber(min, max) {
  let totalEle = max - min + 1;
  let result = Math.floor(Math.random() * totalEle) + min;
  return result;
}
function createArrayOfNumber(start, end) {
  let myArray = [];
  for (let i = start; i <= end; i++) {
    myArray.push(i);
  }
  return myArray;
}
let numbersArray = createArrayOfNumber(1, 10);

clickMe.addEventListener('click', () => {
  if (numbersArray.length === 0) {
    console.log('No more random number');
    return;
  }
  let randomIndex = getRandomNumber(0, numbersArray.length - 1);
  let randomNumber = numbersArray[randomIndex];
  numbersArray.splice(randomIndex, 1);
  console.log(randomNumber);
});
let items = [1,25,"JavaScript",69,"css","34","keep coding","html"];
console.log(items)

//shuffle array
function shuffle(arr){
  for(let i =arr.length-1;i>0;i--){
    const j = Math.floor(Math.random() * (i+1));
    [arr[i],arr[j]] = [arr[j],arr[i]];
  }
  return arr
}
console.log(shuffle(items))

//shuffle selected index 
const  itemToShuffle = items.slice(3,7);
console.log(shuffle(itemToShuffle))

//items after shuffling item from index 3 to 7
items = [items[0],items[1],items[2],...itemToShuffle,items[7]]
console.log(items)
const arr = [333,1,2,11,22,3,4]
console.log(arr.sort())

arr.sort((a,b)=>a-b)

console.log(arr)
const arr = ["Apple",45,"","google",null],,,,"facebook","",69]

const removeEle = arr.filter((el)=> return el !=null && el != "")
function isEqual(arr1,arr2){
  let x = arr1.length;
  let y = arr2.lenght;
  
  //if lenght of array are not equal means array are not equal 
  if(x !=  y) return false;
  
  //sorting both array
  x.sort();
  y.sort();
  
  // Linearly compare elements
  for(let i=0;i<x;i++){
    if(x[i] != y[i]) return false
  }
  // If all elements were same.
    return true
}

let arrayOne = [3, 5, 2, 5, 2]
let arrayTwo = [2, 3, 5, 5, 2]

isEqual(arrayOne,arrayTwo) ? console.log("Matched") : console.log("Not Match")
$oneDimensionalArray = array_map('current', $twoDimensionalArray);

/*
current() function returns the value of the current element in an array. for ex : $fruits = array("banana", "apple", "orange"); echo current($fruits) //will return "banana" since current pointer is on index 0 which is banana
*/
 const arr = ["This", "Little", "Piggy"];
const first = arr.slice(0, 1);
const the_rest = arr.slice(1);console.log(first); // ["This"]
console.log(the_rest); // ["Little", "Piggy"]                               
                                
for (int i = 0; i < n; i++)
{
    if (valCount.ContainsKey(x))
        valCount[x]++;
    else
        valCount[x] = 1;
}
itemList.stream()
          .filter(item -> item.getPropertyList()
                         .stream().anyMatch(property -> property.getKey().equals("Test")))
           .collect(Collectors.toList());
star

Wed Mar 27 2024 22:19:09 GMT+0000 (Coordinated Universal Time)

#php #array
star

Wed Dec 13 2023 08:39:36 GMT+0000 (Coordinated Universal Time)

#javascript #array #dummy
star

Mon Oct 16 2023 21:25:11 GMT+0000 (Coordinated Universal Time)

#javascript #array
star

Mon Sep 04 2023 05:13:11 GMT+0000 (Coordinated Universal Time)

#javascript #array #filter
star

Mon Aug 28 2023 21:14:16 GMT+0000 (Coordinated Universal Time)

#javascript #pagination #array #of #arrays
star

Mon Jul 17 2023 17:59:39 GMT+0000 (Coordinated Universal Time)

#insertionsort #array #sorting
star

Mon Jun 19 2023 06:59:26 GMT+0000 (Coordinated Universal Time) https://practice.geeksforgeeks.org/problems/rearrange-an-array-with-o1-extra-space3142/1

#c++ #cyclic_rotation #rearrangement #array #o(1)_space
star

Sat May 20 2023 20:52:04 GMT+0000 (Coordinated Universal Time) https://www.codewars.com/kata/57cc975ed542d3148f00015b/solutions/javascript

#javascript #array #.includes()
star

Sat May 20 2023 20:34:22 GMT+0000 (Coordinated Universal Time) https://www.codewars.com/kata/57a0e5c372292dd76d000d7e/solutions/javascript

#javascript #array #.repeat()
star

Sat May 20 2023 15:44:06 GMT+0000 (Coordinated Universal Time) https://www.codewars.com/kata/53af2b8861023f1d88000832/solutions/javascript

#javascript #array #chatat()
star

Sat May 20 2023 15:06:17 GMT+0000 (Coordinated Universal Time) https://www.codewars.com/kata/5bb904724c47249b10000131/solutions/javascript

#javascript #operaciónmate #array #.reduce() #parseint()
star

Sat May 20 2023 14:49:00 GMT+0000 (Coordinated Universal Time) https://www.codewars.com/kata/5715eaedb436cf5606000381/solutions/javascript

#javascript #array #operaciónmate #for
star

Sat May 20 2023 13:37:32 GMT+0000 (Coordinated Universal Time) https://www.codewars.com/users/MeridaK/completed_solutions

#javascript #array #.reduce() #if #.length
star

Sat May 20 2023 13:09:11 GMT+0000 (Coordinated Universal Time) https://www.codewars.com/kata/56676e8fabd2d1ff3000000c/solutions/javascript

#javascript #array #buscar #.indexof()
star

Sat May 20 2023 12:55:22 GMT+0000 (Coordinated Universal Time) https://www.codewars.com/kata/53dc23c68a0c93699800041d/solutions/javascript

#javascript #convertir #array #.join()
star

Sat May 20 2023 10:33:44 GMT+0000 (Coordinated Universal Time)

#javascript #operadordepropagación #array
star

Sat May 20 2023 10:10:48 GMT+0000 (Coordinated Universal Time) https://www.codewars.com/kata/577a98a6ae28071780000989/solutions/javascript

#javascript #operación #operadordepropagación #array
star

Thu May 18 2023 21:34:14 GMT+0000 (Coordinated Universal Time) https://www.codewars.com/kata/55cbd4ba903825f7970000f5/solutions/javascript

#javascript #operación #array #.reduce #.length
star

Thu May 18 2023 21:14:26 GMT+0000 (Coordinated Universal Time) https://www.codewars.com/kata/reviews/516f302a7c907a79f200069f/groups/516f302a7c907a79f20006ad

#javascript #convertir #array #.split() #.join() #.reverse()
star

Thu May 18 2023 17:18:30 GMT+0000 (Coordinated Universal Time)

#javascript #remover #array #.slice()
star

Wed Apr 05 2023 22:21:51 GMT+0000 (Coordinated Universal Time) https://codetogo.io/how-to-sort-array-of-objects-in-ascending-order-in-javascript/

#javascript #array #object #sort #order
star

Wed Apr 05 2023 22:15:04 GMT+0000 (Coordinated Universal Time) https://codetogo.io/how-to-flatten-a-nested-array-in-javascript/

#javascript #flatten #array
star

Wed Apr 05 2023 22:14:21 GMT+0000 (Coordinated Universal Time) https://codetogo.io/how-to-filter-objects-in-array-in-javascript/

#javascript #array #filter #object
star

Wed Apr 05 2023 22:13:41 GMT+0000 (Coordinated Universal Time) https://codetogo.io/how-to-empty-array-in-javascript/

#javascript #array
star

Wed Apr 05 2023 16:08:37 GMT+0000 (Coordinated Universal Time) https://codetogo.io/how-to-create-object-from-array-in-javascript/

#javascript #object #transform #array
star

Wed Apr 05 2023 16:07:59 GMT+0000 (Coordinated Universal Time) https://codetogo.io/how-to-create-array-from-existing-array-in-javascript/

#javascript #array #create
star

Wed Apr 05 2023 16:07:09 GMT+0000 (Coordinated Universal Time) https://codetogo.io/how-to-convert-array-to-comma-separated-string-in-javascript/

#javascript #join #array #string
star

Wed Apr 05 2023 16:05:45 GMT+0000 (Coordinated Universal Time) https://codetogo.io/how-to-concatenate-arrays-in-javascript/

#javascript #array #arrays #join
star

Wed Apr 05 2023 16:02:51 GMT+0000 (Coordinated Universal Time) https://codetogo.io/how-to-check-if-array-includes-element-in-javascript/

#javascript #array
star

Wed Apr 05 2023 16:01:56 GMT+0000 (Coordinated Universal Time) https://codetogo.io/how-to-apply-function-to-every-array-element-in-javascript/

#javascript #array #every #loop #function
star

Wed Apr 05 2023 16:01:06 GMT+0000 (Coordinated Universal Time) https://codetogo.io/how-to-add-item-to-array-in-javascript/

#javascript #array
star

Tue Feb 07 2023 08:36:03 GMT+0000 (Coordinated Universal Time)

#javascript #array
star

Sat Dec 24 2022 05:07:10 GMT+0000 (Coordinated Universal Time)

#array #dataset #html
star

Mon Dec 19 2022 23:12:50 GMT+0000 (Coordinated Universal Time)

#reduce #array #map #filter
star

Mon Nov 21 2022 15:45:58 GMT+0000 (Coordinated Universal Time) https://stackoverflow.com/questions/14266730/js-how-to-cache-a-variable

#php #array #javascript
star

Mon Oct 31 2022 02:35:21 GMT+0000 (Coordinated Universal Time)

#array #at
star

Thu Oct 06 2022 05:53:45 GMT+0000 (Coordinated Universal Time)

#javascript #array #duplicate
star

Sat Jul 23 2022 19:56:49 GMT+0000 (Coordinated Universal Time) https://sharepains.com/2019/04/01/update-a-multi-select-choice-power-automate/

#powerautomate #multiselect #sharepoint #array #select
star

Tue Jul 12 2022 09:37:40 GMT+0000 (Coordinated Universal Time) https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/es6/write-concise-object-literal-declarations-using-object-property-shorthand

#array #object #destructure #parameter #arrowfunction
star

Tue Jul 12 2022 09:23:55 GMT+0000 (Coordinated Universal Time) https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-to-pass-an-object-as-a-functions-parameters

#array #object #destructure #parameter #arrowfunction
star

Tue Jul 12 2022 05:31:55 GMT+0000 (Coordinated Universal Time) https://www.w3schools.com/jsref/jsref_map.asp

#array #object #map #join
star

Thu Jul 07 2022 21:47:01 GMT+0000 (Coordinated Universal Time)

#javascript #array #quicksort
star

Thu Jun 30 2022 02:13:50 GMT+0000 (Coordinated Universal Time)

#javascript #array #set
star

Tue Jun 28 2022 23:46:22 GMT+0000 (Coordinated Universal Time) https://dev.to/ptable/two-dimensional-array-search-4b2g

#array #search
star

Wed Jun 15 2022 05:17:16 GMT+0000 (Coordinated Universal Time)

#ios #swift #update #dictionary #array
star

Tue Jun 14 2022 09:49:00 GMT+0000 (Coordinated Universal Time)

#ios #swift #update #dictionary #array
star

Sun Apr 24 2022 23:24:44 GMT+0000 (Coordinated Universal Time) https://www.programiz.com/csharp-programming/multidimensional-arrays

#array
star

Wed Feb 23 2022 16:31:20 GMT+0000 (Coordinated Universal Time)

#javascript #array #groupby
star

Tue Feb 08 2022 09:38:53 GMT+0000 (Coordinated Universal Time) https://practice.geeksforgeeks.org/problems/make-matrix-beautiful-1587115620/1/?track=DSASP-Matrix&batchId=190

#java #gfg #geeksforgeeks #2d #array #matrix #practice #beautifulmatrix
star

Tue Feb 08 2022 09:35:30 GMT+0000 (Coordinated Universal Time) https://practice.geeksforgeeks.org/problems/boolean-matrix-problem-1587115620/1/?track=DSASP-Matrix&batchId=190

#java #gfg #geeksforgeeks #2d #array #matrix #practice #booleanmatrix
star

Tue Feb 08 2022 09:32:41 GMT+0000 (Coordinated Universal Time) https://practice.geeksforgeeks.org/problems/reversing-the-rows-of-a-matrix-1587115621/1/?track=DSASP-Matrix&batchId=190

#java #gfg #geeksforgeeks #2d #array #matrix #practice #interchangingrows
star

Tue Feb 08 2022 08:47:50 GMT+0000 (Coordinated Universal Time) https://practice.geeksforgeeks.org/problems/reversing-the-columns-of-a-matrix-1587115621/1/?track=DSASP-Matrix&batchId=190

#java #gfg #geeksforgeeks #2d #array #matrix #practice #reversingcolumns
star

Tue Feb 08 2022 08:41:01 GMT+0000 (Coordinated Universal Time) https://practice.geeksforgeeks.org/problems/exchange-matrix-columns-1587115620/1/?track=DSASP-Matrix&batchId=190

#java #gfg #geeksforgeeks #2d #array #matrix #practice #exchangecolumns
star

Tue Feb 08 2022 08:29:37 GMT+0000 (Coordinated Universal Time) https://practice.geeksforgeeks.org/problems/determinant-of-a-matrix-1587115620/1/?track=DSASP-Matrix&batchId=190

#java #gfg #geeksforgeeks #2d #array #matrix #practice #determinant
star

Tue Feb 08 2022 08:21:15 GMT+0000 (Coordinated Universal Time) https://practice.geeksforgeeks.org/problems/multiply-the-matrices-1587115620/1/?track=DSASP-Matrix&batchId=190

#java #gfg #geeksforgeeks #2d #array #matrix #practice #multiplication
star

Tue Feb 08 2022 08:14:36 GMT+0000 (Coordinated Universal Time) https://practice.geeksforgeeks.org/problems/sum-of-upper-and-lower-triangles-1587115621/1/?track=DSASP-Matrix&batchId=190

#java #gfg #geeksforgeeks #2d #array #matrix #practice #sum
star

Tue Feb 08 2022 08:09:29 GMT+0000 (Coordinated Universal Time) https://practice.geeksforgeeks.org/problems/adding-two-matrices3512/1/?track=DSASP-Matrix&batchId=190

#java #gfg #geeksforgeeks #2d #array #matrix #addition #practice
star

Tue Feb 08 2022 07:29:55 GMT+0000 (Coordinated Universal Time)

#java #gfg #geeksforgeeks #lecture #2d #array #matrix #transpose
star

Tue Jan 18 2022 10:48:29 GMT+0000 (Coordinated Universal Time)

#ios #swift #xcode #sort #array #sortarray
star

Sat Jan 15 2022 19:01:04 GMT+0000 (Coordinated Universal Time)

#python #javascript #array #list #forloop #iteration
star

Thu Jan 13 2022 10:58:19 GMT+0000 (Coordinated Universal Time) https://stackoverflow.com/questions/48467867/adding-a-filter-to-an-array-in-swift-4

#swift #filter #array #ios
star

Thu Dec 16 2021 23:06:21 GMT+0000 (Coordinated Universal Time) https://stackoverflow.com/questions/5767325/how-can-i-remove-a-specific-item-from-an-array

#javascript #array
star

Wed Oct 13 2021 12:06:23 GMT+0000 (Coordinated Universal Time) https://www.codecademy.com/courses/introduction-to-javascript/projects/secret-message

#javascript #array
star

Thu Sep 16 2021 08:36:20 GMT+0000 (Coordinated Universal Time)

#php #sort #array
star

Thu Aug 19 2021 17:17:11 GMT+0000 (Coordinated Universal Time) https://github.com/airbnb/javascript

#array
star

Sun Jul 04 2021 13:14:30 GMT+0000 (Coordinated Universal Time) https://www.samanthaming.com/tidbits/87-5-ways-to-append-item-to-array/

#array #javscript
star

Tue Jun 29 2021 11:46:34 GMT+0000 (Coordinated Universal Time)

#object #array #javascript #vanilla
star

Tue Jun 29 2021 11:46:09 GMT+0000 (Coordinated Universal Time)

#object #array #javascript #vanilla
star

Tue Jun 29 2021 11:45:24 GMT+0000 (Coordinated Universal Time)

#object #array #javascript #vanilla
star

Tue Jun 29 2021 09:34:54 GMT+0000 (Coordinated Universal Time) https://upmostly.com/tutorials/react-filter-filtering-arrays-in-react-with-examples

#array #react.js #javascript #react #filter #map
star

Tue Jun 29 2021 09:30:58 GMT+0000 (Coordinated Universal Time)

#array #react.js #javascript #react #filter #map
star

Tue Jun 29 2021 09:28:03 GMT+0000 (Coordinated Universal Time)

#array #destructuring #javasc #react.js
star

Thu Jun 24 2021 16:18:30 GMT+0000 (Coordinated Universal Time)

#array #destructuring #javasc #react.js
star

Thu Jun 24 2021 16:12:14 GMT+0000 (Coordinated Universal Time)

#array #destructuring #javasc #react.js
star

Thu Jun 24 2021 13:53:56 GMT+0000 (Coordinated Universal Time)

#modx #instagram #curl #json #array #tpl
star

Tue Jun 22 2021 08:15:53 GMT+0000 (Coordinated Universal Time)

#javascript #vanilla #array
star

Mon Jun 21 2021 15:11:34 GMT+0000 (Coordinated Universal Time)

#javascript #vanilla #array
star

Sat Jun 19 2021 07:31:06 GMT+0000 (Coordinated Universal Time)

#javascript #vanilla #sort #randomize #array
star

Sat Jun 19 2021 07:10:34 GMT+0000 (Coordinated Universal Time)

#javascript #vanilla #sort #randomize #array
star

Fri Apr 16 2021 07:42:52 GMT+0000 (Coordinated Universal Time) https://playcode.io/757523/

#javascript #array #random #randomarray #dom
star

Thu Apr 08 2021 10:16:24 GMT+0000 (Coordinated Universal Time) https://playcode.io/754960/

#javascript #array #shuffle
star

Fri Apr 02 2021 08:01:12 GMT+0000 (Coordinated Universal Time)

#javascript #array #sort
star

Fri Apr 02 2021 07:12:07 GMT+0000 (Coordinated Universal Time)

#javascript #array #emptyarray
star

Fri Apr 02 2021 06:52:39 GMT+0000 (Coordinated Universal Time)

#javascript #array
star

Mon Nov 30 2020 14:23:00 GMT+0000 (Coordinated Universal Time) https://stackoverflow.com/questions/8754980/how-to-convert-two-dimensional-array-to-one-dimensional-array-in-php5

#php #array
star

Fri Apr 24 2020 11:44:23 GMT+0000 (Coordinated Universal Time) https://css-tricks.com/snippets/javascript/getting-first-and-last-items-in-array-and-splitting-all-the-rest/

#css #css #items #array
star

Wed Apr 01 2020 08:37:24 GMT+0000 (Coordinated Universal Time) https://stackoverflow.com/questions/60966491/how-to-clear-item-not-input-when-count-frequency-use-dictionary-c-sharp

#C# #c# #array #dictionary
star

Wed Apr 01 2020 08:28:49 GMT+0000 (Coordinated Universal Time) https://stackoverflow.com/questions/60966469/how-to-find-an-element-in-array-of-object-with-streams

#java #java #stream #array

Save snippets that work with our extensions

Available in the Chrome Web Store Get Firefox Add-on Get VS Code extension