From fe0a2a2feefcecddb024b5201930c839f943d62b Mon Sep 17 00:00:00 2001 From: Manthan Ankolekar Date: Mon, 7 Oct 2024 17:38:52 +0530 Subject: [PATCH] chore: added questions --- README.md | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/README.md b/README.md index 77ef725..5814d47 100644 --- a/README.md +++ b/README.md @@ -7115,6 +7115,50 @@ const numbers = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5]; console.log(findMin(numbers)); // Output: 1 ``` +Remove special characters from the given string without using built-in methods: + +```javascript +const input = "MA@NT+H(A+N)"; + +const remove = (str) => { + let result = ''; + for (let i = 0; i < str.length; i++){ + let char = str[i]; + if( + (char >= 'A' && char <= 'Z') || + (char >= 'a' && char <= 'z') || + (char >= '0' && char <= '9') || + char === ' ' + ){ + result += char; + } + } + return result; +} + +console.log(remove(input)); // Output=MANTHAN +``` + +Print the given values in matrix form without using built-in methods + +```javascript +Output: +1 4 7 +2 5 8 +3 6 9 + +let input = [1, 2, 3, 4, 5, 6, 7, 8, 9]; + +// Manually print the matrix +for (let row = 0; row < 3; row++) { + let output = ""; // Initialize an empty string for each row + for (let col = 0; col < 3; col++) { + output += input[row + col * 3] + " "; // Calculate index and add spaces + } + console.log(output); +} +``` + Write a function that calculates the sum of an array of numbers Without Inbuilt Method. ```javascript