Skip to content

Commit 49ea6ff

Browse files
solved just 2 more problems
1 parent 83a4a5b commit 49ea6ff

File tree

2 files changed

+59
-0
lines changed

2 files changed

+59
-0
lines changed

F. Function/includes-number.js

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/* Problem-7
2+
3+
You are given an array of numbers. Count how many times the a number is repeated in the array.
4+
5+
sample-input: numbers = [5,6,11,12,98, 5] find: 5 output: 2
6+
7+
sample-input: numbers = [5,6,11,12,98, 5] find: 25 output: 0
8+
*/
9+
function countNumber(numbers, find) {
10+
let findingNum = 0;
11+
for (let i = 0; i < numbers.length; i++) {
12+
if (numbers[i] === find) {
13+
findingNum++;
14+
}
15+
}
16+
return `Number 5 is repeated ${findingNum} times`;
17+
18+
}
19+
20+
const arrayNumbers = [5, 6, 11, 12, 98, 5];
21+
const find = 5;
22+
const result = countNumber(arrayNumbers, find)
23+
console.log(result);
24+
25+
26+
27+
function checkNum(numbers) {
28+
let get25 = 0;
29+
for (let i = 0; i < numbers.length; i++) {
30+
if (numbers[i] === find2) {
31+
get25++;
32+
}
33+
}
34+
35+
return get25;
36+
}
37+
38+
39+
const numbers2 = [5, 6, 11, 12, 98, 5];
40+
const find2 = 25;
41+
const result2 = checkNum(numbers2, find2)
42+
console.log('Output', result2);

F. Function/temperature.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/* Problem-6
2+
3+
Write a function to convert temperature from Celsius to Fahrenheit. & Celsius to kelvin & fahrenheit to celsius.
4+
5+
*/
6+
7+
// Celsius to Fahrenheit
8+
function convertTemp(temperature) {
9+
const celsiusToFahrenheit = temperature * (9 / 5) + 32;
10+
const celsiusToKelvin = temperature + 273.15;
11+
const fahrenheitCelsius = parseFloat((temperature - 32) * 5 / 9).toFixed(2);
12+
const result = 'Temperature is= ' + celsiusToFahrenheit + '°F ' + celsiusToKelvin + 'K ' + fahrenheitCelsius + '°C';
13+
return result;
14+
15+
}
16+
const temperature = convertTemp(0);
17+
console.log(temperature);

0 commit comments

Comments
 (0)