Skip to content

Commit 6f25cec

Browse files
author
umbur
committed
completes sayHelloBye
1 parent dcf85df commit 6f25cec

File tree

3 files changed

+62
-10
lines changed

3 files changed

+62
-10
lines changed

equal.js

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// Create a function that takes three integer arguments (a, b, c) and returns the amount of integers which are of equal value.
2+
3+
// Examples:
4+
// equal(3, 4, 3) ➞ 2
5+
// equal(1, 1, 1) ➞ 3
6+
// equal(3, 4, 1) ➞ 0
7+
8+
// Notes:
9+
// Your function must return 0, 2 or 3.
10+
11+
function equal(a, b, c) {
12+
const size = new Set([a, b, c]).size;
13+
// console.log(size);
14+
return size === 3 ? 0 : 4 - size;
15+
}
16+
console.log(equal(1, 3, 3));
17+
18+
// Solution 2
19+
// function equal(a, b, c) {
20+
// if (a === b && a === c) {
21+
// return 3;}
22+
// if (a === b || a === c || b === c) {
23+
// return 2;}
24+
// return 0;
25+
// }

js_draft.js

+15-10
Original file line numberDiff line numberDiff line change
@@ -269,13 +269,18 @@
269269
// }
270270
// console.log(num_of_digits(-123));
271271

272-
function arrayOperation(x, y, n) {
273-
let test = [];
274-
for (let i = x; i <= y; i++) {
275-
if (i % n === 0) {
276-
test.push(i);
277-
}
278-
}
279-
return test;
280-
}
281-
console.log(arrayOperation(1, 10, 3));
272+
// function arrayOperation(x, y, n) {
273+
// let test = [];
274+
// for (let i = x; i <= y; i++) {
275+
// if (i % n === 0) {
276+
// test.push(i);
277+
// }
278+
// }
279+
// return test;
280+
// }
281+
// console.log(arrayOperation(1, 10, 3));
282+
283+
// function equal(a, b, c) {
284+
285+
// }
286+
// console.log(equal(3, 4, 3))

sayHelloBye.js

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Write a function that takes a string name and a number num (either 0 or 1) and return "Hello" + name if num is 1, otherwise return
2+
// "Bye" + name.
3+
4+
// Examples:
5+
// sayHelloBye("alon", 1) ➞ "Hello Alon"
6+
// sayHelloBye("Tomi", 0) ➞ "Bye Tomi"
7+
// sayHelloBye("jose", 0) ➞ "Bye Jose"
8+
9+
// Notes:
10+
// The name you return must be capitalized.
11+
12+
function sayHelloBye(name, num) {
13+
let test = name[0];
14+
// console.log(name.slice(1));
15+
if (num === 1) {
16+
return "Hello" + " " + test.toUpperCase() + name.slice(1);
17+
} else if (num === 0) {
18+
return "Bye" + " " + test.toUpperCase() + name.slice(1);
19+
}
20+
}
21+
console.log(sayHelloBye("alon", 1));
22+
console.log(sayHelloBye("Tomi", 0));

0 commit comments

Comments
 (0)