Skip to content

Commit e0b154b

Browse files
committed
initial push
0 parents  commit e0b154b

File tree

5 files changed

+4467
-0
lines changed

5 files changed

+4467
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules/

demo.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
//function to calculate the area of a circle
2+
function calculateArea(radius) {
3+
return Math.PI * Math.pow(radius, 2);
4+
}
5+
6+
//function to validate an email address using regex
7+
function validateEmail(email) {
8+
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
9+
return emailRegex.test(email);
10+
}
11+
12+
//function to fetch data from an API and log the response
13+
async function fetchData(url) {
14+
try {
15+
const response = await fetch(url);
16+
if (!response.ok) {
17+
throw new Error(`HTTP error! status: ${response.status}`);
18+
}
19+
const data = await response.json();
20+
console.log(data);
21+
} catch (error) {
22+
console.error('Error fetching data:', error);
23+
}
24+
}

demo.test.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
const { myFunction } = require('./demo');
2+
3+
test('myFunction should return expected value', () => {
4+
expect(myFunction()).toBe('expected value');
5+
});

0 commit comments

Comments
 (0)