File tree Expand file tree Collapse file tree 5 files changed +4467
-0
lines changed
Expand file tree Collapse file tree 5 files changed +4467
-0
lines changed Original file line number Diff line number Diff line change 1+ node_modules /
Original file line number Diff line number Diff line change 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+ }
Original file line number Diff line number Diff line change 1+ const { myFunction } = require ( './demo' ) ;
2+
3+ test ( 'myFunction should return expected value' , ( ) => {
4+ expect ( myFunction ( ) ) . toBe ( 'expected value' ) ;
5+ } ) ;
You can’t perform that action at this time.
0 commit comments