Skip to content

Commit 1b59a29

Browse files
Added day 6 challenges and first day 7 challenge
1 parent fb2fefd commit 1b59a29

File tree

3 files changed

+47
-0
lines changed

3 files changed

+47
-0
lines changed

Day 6/Bitwise Operators.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/*
2+
* Return the largest value of any a & b < k in S (where a < b).
3+
*
4+
* n: Set S is a sequence of distinct integers from 1 to n (i.e., {1, 2, ..., n}).
5+
* k: An integer.
6+
*/
7+
function getMaxLessThanK(n, k) {
8+
let maximum = 0;
9+
let current = -1;
10+
for (let i = 1; i < n; i++)
11+
{
12+
for (let j = i + 1; j <= n; j++)
13+
{
14+
current = i & j;
15+
if (current < k && current > maximum)
16+
{
17+
maximum = current;
18+
}
19+
}
20+
}
21+
return maximum;
22+
}

Day 6/JavaScript Dates.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// The days of the week are: "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"
2+
function getDayName(dateString) {
3+
let dayName;
4+
// Write your code here
5+
6+
var day_names = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]
7+
var date = new Date(dateString);
8+
9+
dayName = day_names[date.getDay()];
10+
11+
return dayName;
12+
}

Day 7/Regular Expressions I.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
function regexVar() {
2+
/*
3+
* Declare a RegExp object variable named 're'
4+
* It must match a string that starts and ends with the same vowel (i.e., {a, e, i, o, u})
5+
*/
6+
7+
var re = RegExp(/^([aeiou]).*\1$/);
8+
9+
/*
10+
* Do not remove the return statement
11+
*/
12+
return re;
13+
}

0 commit comments

Comments
 (0)