Min & Max Values in Array
given an array myArray of integers, write a JS program to find the maximum and minimum values in the array.
input1
[1,4,2,7,9,3,5]
output1
{min: 1, max: 9}
"use strict";
process.stdin.resume();
process.stdin.setEncoding("utf-8");
let inputString = "";
let currentLine = 0;
process.stdin.on("data", (inputStdin) => {
inputString += inputStdin;
});
process.stdin.on("end", (_) => {
inputString = inputString
.trim()
.split("\n")
.map((str) => str.trim());
main();
});
function readLine() {
return inputString[currentLine++];
}
/* Please do not modify anything above this line */
function findMinAndMaxValuesInArray(arr) {
/* Write your code here */
}
/* Please do not modify anything below this line */
function main() {
let myArray = JSON.parse(readLine());
console.log(findMinAndMaxValuesInArray(myArray));
}
Write a program to print this pattern
Input=4
Output
1357
3571
5731
7531
The function accepts two positive integers ‘r’ and ‘unit’ and a positive integer array ‘arr’ of size ‘n’ as its argument ‘r’ represents the number of rats present in an area, ‘unit’ is the amount of food each rat consumes and each ith element of array ‘arr’ represents the amount of food present in ‘i+1’ house number, where 0 <= i
Note:
Return -1 if the array is null
Return 0 if the total amount of food from all houses is not sufficient for all the rats.
Computed values lie within the integer range.
Example:
Input:
r: 7
unit: 2
n: 8
arr: 2 8 3 5 7 4 1 2
Output:
4
Explanation:
Total amount of food required for all rats = r * unit
= 7 * 2 = 14.
The amount of food in the 1st 4 houses = 2+8+3+5 = 18. Since, amount of food in 1st 4 houses is sufficient for all the rats. Thus, output is 4.
take a function to check no is prime or not from array and then is number is prime add 1 to element if not then multiply by 2..note: Use arrow function to add or multiply element part
The function accepts two positive integers ‘r’ and ‘unit’ and a positive integer array ‘arr’ of size ‘n’ as its argument ‘r’ represents the number of rats present in an area, ‘unit’ is the amount of food each rat consumes and each ith element of array ‘arr’ represents the amount of food present in ‘i+1’ house number, where 0 <= i
Capital and Country
The goal of this coding exam is to quickly get you off the ground with HTML select element
Use the below reference image
https://assets.ccbp.in/frontend/content/dynamic-webapps/capital-and-country-op.gif
Achieve the design with HTML, CSS, and functionality with JS
Warning
Do not delete the prefilled code in JS.
Note
HTML option element should consist of selected as an attribute for the value newDelhi by default.
CCBP Login
The goal of this coding exam is to quickly get you off the ground with CCBP Login Page
Use the below reference image
https://assets.ccbp.in/frontend/content/dynamic-webapps/ccbp-login-op.gif
Achieve the given functionality using JS
Bike Search
The goal of this coding exam is to quickly get you off the ground with HTML search input element and Bootstrap spinner
Use the below reference image.
https://assets.ccbp.in/frontend/content/dynamic-webapps/bike-search-op.gif
Instructions
Add the id searchInput to the HTML input element
Achieve the design with HTML, CSS, and functionality with JS
Random Activity
The goal of this coding exam is to quickly get you off the ground with the DOM Manipulations.
Refer to the below image.
https://assets.ccbp.in/frontend/content/dynamic-webapps/random-activity-output.gif
Achieve the given functionality using JS.
Keyboard Events
The goal of this coding exam is to quickly get you off the ground with Keydown event
Use the below reference image
https://assets.ccbp.in/frontend/content/dynamic-webapps/keyboard-event-op.gif
Achieve the given functionality using JS