From 2d165facb56820331bab864a229aa72cdde2452d Mon Sep 17 00:00:00 2001 From: Numan Ahmed Date: Sat, 2 Oct 2021 21:40:15 +0530 Subject: [PATCH] Add element at the Beginning/End/Index --- Array/arrayOperations.js | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/Array/arrayOperations.js b/Array/arrayOperations.js index f0b514e..7c3aea0 100644 --- a/Array/arrayOperations.js +++ b/Array/arrayOperations.js @@ -4,8 +4,8 @@ const strings = ['n', 'u', 'm']; /** * Add element at the End */ -strings.push('a'); -strings.push('n'); +strings.push('d'); +strings.push('e'); /** @@ -14,6 +14,24 @@ strings.push('n'); strings.pop(); +/** + * Add element at the Beginning + */ +strings.unshift('D') +strings.unshift('e') + + +/** + * Remove First element + */ +strings.shift(); + + +/** + * Add element at the Index + */ +strings.splice(4, 0, 'Num',); + console.log(strings); \ No newline at end of file