This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function ValidateEmail(mail) { | |
| if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(mail)) { | |
| return (true) | |
| } | |
| //alert("You have entered an invalid email address!") | |
| return (false) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function isNumberKey(evt) | |
| { | |
| var charCode = (evt.which) ? evt.which : event.keyCode | |
| if (charCode > 31 && (charCode < 48 || charCode > 57)) | |
| return false; | |
| return true; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <meta http-equiv="X-UA-Compatible" content="ie=edge"> | |
| <title>Document</title> | |
| <style> | |
| /* MODAL*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function binaryGap(N) { | |
| let str = N.toString(2); | |
| let startPos; | |
| let endPos; | |
| let res = []; | |
| res.push(0); | |
| console.log(str) | |
| for (let i = 1; i < str.length; i++) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // add() function is called with arguments a, b | |
| // and callback, callback will be executed just | |
| // after ending of add() function | |
| function add(a, b , callback){ | |
| document.write(`The sum of ${a} and ${b} is ${a+b}.` +"<br>"); | |
| callback(); | |
| } | |
| // disp() function is called just | |
| // after the ending of add() function |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let p = new Promise((resolve, reject) => { | |
| var imgData = 'data'; // this is always true | |
| if (imgData) { | |
| // This happens when the imgData returns true | |
| resolve('Resolved'); | |
| } | |
| else { | |
| // This happens when imgData returns false; |