{"id":22364005,"url":"https://github.com/mfarhadattari/problem-solving-js-scic","last_synced_at":"2025-03-26T15:19:43.641Z","repository":{"id":183671806,"uuid":"670547379","full_name":"mfarhadattari/problem-solving-js-scic","owner":"mfarhadattari","description":null,"archived":false,"fork":false,"pushed_at":"2023-07-25T15:12:13.000Z","size":10,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-31T16:35:48.608Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mfarhadattari.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-07-25T09:46:33.000Z","updated_at":"2023-07-25T10:02:26.000Z","dependencies_parsed_at":null,"dependency_job_id":"93e1fd53-cccd-4f7b-8894-6298faac8f8e","html_url":"https://github.com/mfarhadattari/problem-solving-js-scic","commit_stats":null,"previous_names":["mfarhadattari/problem-solving-js-scic"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mfarhadattari%2Fproblem-solving-js-scic","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mfarhadattari%2Fproblem-solving-js-scic/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mfarhadattari%2Fproblem-solving-js-scic/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mfarhadattari%2Fproblem-solving-js-scic/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mfarhadattari","download_url":"https://codeload.github.com/mfarhadattari/problem-solving-js-scic/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245678903,"owners_count":20654738,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-04T17:18:00.286Z","updated_at":"2025-03-26T15:19:43.617Z","avatar_url":"https://github.com/mfarhadattari.png","language":"JavaScript","readme":"### Task 1 : Create a function that takes a string as input and returns the reversed version of the string without using the built-in reverse() method.\n\n```javaScript\nconst reverseString = (string) =\u003e {\n  let reversedString = \"\";\n  for (let i = string.length - 1; i \u003e= 0; i--) {\n    reversedString = reversedString + string[i];\n  }\n  return reversedString;\n};\n```\n\n### Task 2 : Create a function that takes an array of numbers as input and returns the sum of all positive numbers in the array.\n\n```javaScript\nconst sumOfPositiveNumber = (arrayOfNumbers) =\u003e {\n  const positiveNumbers = arrayOfNumbers.filter((eachNumber) =\u003e eachNumber \u003e 0);\n  const sumOfPositiveNumber = positiveNumbers.reduce((sum, eachNumber) =\u003e sum + eachNumber, 0);\n  return sumOfPositiveNumber;\n};\n```\n\n### Task 3: Write a JavaScript program to find the most frequent element in an array and return it.\n\n```javaScript\nconst mostFrequentElement = (array) =\u003e {\n  let mostFrequentElement;\n  let highestCount = 0;\n  array.forEach((eachElement) =\u003e {\n    const filtered = array.filter((eachItem) =\u003e eachElement === eachItem);\n    mostFrequentElement = filtered.length \u003e highestCount ? eachElement : mostFrequentElement;\n    highestCount = filtered.length \u003e highestCount ? filtered.length : highestCount;\n  });\n\n  return mostFrequentElement;\n};\n```\n### Task 4: Create a function that takes a sorted array of numbers and a target value as input. The function should find two numbers in the array that add up to the target value. Return an array containing the indices of the two numbers.\n\n```javaScript\nconst findSumIndices = (sortedArray, targetValue) =\u003e {\n  let leftPointer = 0;\n  let rightPointer = sortedArray.length - 1;\n  while (leftPointer \u003c rightPointer) {\n    const [a, b] = [sortedArray[leftPointer], sortedArray[rightPointer]];\n    let currentSum = a + b;\n    if (currentSum === targetValue) {\n      return [a, b];\n    } else if (currentSum \u003e targetValue) {\n      rightPointer--;\n    } else {\n      leftPointer++;\n    }\n  }\n};\n```\n### Task 5: Implement a simple JavaScript calculator. The calculator should take two numbers and an operator (+, -, \\*, /) as input and return the result of the operation.\n\n```JavaScript\nconst arithmeticCalculator = (num1, num2, operation) =\u003e {\n  switch (operation) {\n    case \"+\":\n      return num1 + num2;\n    case \"-\":\n      return num1 - num2;\n    case \"*\":\n      return num1 * num2;\n    case \"/\":\n      return num1 / num2;\n    default:\n      return \"Input Correct Information\";\n  }\n};\n```\n### Task 6: Create a program that generates a random password of a specified length. The password should include a mix of uppercase letters, lowercase letters, numbers, and special characters.\n\n```javaScript\nconst passwordGenerator = (length) =\u003e {\n  const characters =\n    \"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890@#$\u0026*\";\n  let password = \"\";\n  for (let i = 0; i \u003c length; i++) {\n    const index = Math.round(Math.random() * characters.length);\n    password += characters[index];\n  }\n  return password;\n};\n```\n\n### Task 7: Implement a function that converts a Roman numeral to an integer. The function should take a Roman numeral string (e.g., \"IX\" or \"XXI\") as input and return the corresponding integer value.\n\n```javaScript\nconst romanToDecimal = (romanNumeral) =\u003e {\n  romanNumeral = romanNumeral.toUpperCase();\n  const romanValues = { I: 1, V: 5, X: 10, L: 50, C: 100, D: 500, M: 1000 };\n  let totalDecimal = 0;\n  let previousDecimal = 0;\n  for (let i = romanNumeral.length - 1; i \u003e= 0; i--) {\n    const currentDecimal = romanValues[romanNumeral[i]];\n    if (currentDecimal \u003e= previousDecimal) {\n      totalDecimal += currentDecimal;\n    } else {\n      totalDecimal -= currentDecimal;\n    }\n    previousDecimal = currentDecimal;\n  }\n  return totalDecimal;\n};\n```\n\n### Task 8: Implement a JavaScript function to find the second smallest element in an array of numbers. The function should return the second smallest number.\n\n```javaScript\nconst secondSmallestOfArray = (arrayOfNumbers) =\u003e {\n  let smallest = arrayOfNumbers[0];\n  let secondSmallest = arrayOfNumbers[1];\n  arrayOfNumbers.forEach((eachNumber) =\u003e {\n    if (eachNumber \u003c smallest) {\n      secondSmallest = smallest;\n      smallest = eachNumber;\n    } else if (eachNumber \u003e smallest \u0026\u0026 eachNumber \u003c secondSmallest) {\n      secondSmallest = eachNumber;\n    }\n  });\n  return secondSmallest;\n};\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmfarhadattari%2Fproblem-solving-js-scic","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmfarhadattari%2Fproblem-solving-js-scic","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmfarhadattari%2Fproblem-solving-js-scic/lists"}