New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

rootedbox-two-d-array

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rootedbox-two-d-array

easy create 2 d arrays

latest
Source
npmnpm
Version
1.0.1
Version published
Maintainers
1
Created
Source

two-d-array

A simple utility to create a 2D array with specified dimensions and a default value.

Installation

Install the package using npm:

npm install rootedbox-two-d-array

or yarn

yarn add rootedbox-two-d-array

Usage

Require the package in your JavaScript or Node.js project:

const twoDArray = require('yourusername-two-d-array');

Then, use the twoDArray function to create a new 2D array with the desired dimensions and default value:

const rows = 3;
const cols = 4;
const defaultValue = 0;

const myArray = twoDArray(rows, cols, defaultValue);

console.log(myArray);
// Output:
// [
//   [0, 0, 0, 0],
//   [0, 0, 0, 0],
//   [0, 0, 0, 0]
// ]

If you don't provide a default value, the array will be filled with null:

const myArray = twoDArray(rows, cols);

console.log(myArray);
// Output:
// [
//   [null, null, null, null],
//   [null, null, null, null],
//   [null, null, null, null]
// ]

Keywords

2d

FAQs

Package last updated on 30 Apr 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts