Skip to content

Instantly share code, notes, and snippets.

View i-anshuman's full-sized avatar
🎯
Focusing

Anshuman Gupta i-anshuman

🎯
Focusing
View GitHub Profile
@i-anshuman
i-anshuman / indiamart.js
Last active September 2, 2020 07:15
Data Scraping From Web Pages
function IndiaMart() {
let numbers = [];
let nodes = document.querySelectorAll('.pns_h');
for(let i = 0; i < nodes.length; i++) {
numbers.push(nodes[i].innerHTML);
}
return numbers;
}
console.log(IndiaMart());
@i-anshuman
i-anshuman / quotes.json
Last active December 31, 2019 16:01
Quotes
{
"quotes": [
{
"quote": "Life isn’t about getting and having, it’s about giving and being.",
"author": "Kevin Kruse"
},
{
"quote": "Whatever the mind of man can conceive and believe, it can achieve.",
"author": "Napoleon Hill"
},
var form = document.getElementById("addForm");
var taskList = document.getElementById("items");
var input = document.getElementById("new_task");
//Form add event
form.addEventListener("submit", addTask);
// Delete event
taskList.addEventListener("click", removeItem);
@i-anshuman
i-anshuman / cashRegister.js
Last active November 20, 2019 14:12
FreeCodeCamp
'use strict';
const denominationTypes = {
'PENNY': 0.01,
'NICKEL': 0.05,
'DIME': 0.1,
'QUARTER': 0.25,
'ONE': 1,
'FIVE': 5,
'TEN': 10,
'use strict';
const telephoneCheck = (str) => {
const validNumber = /^[1{1}]?[ ]?(\(\d{3}\)|\d{3})[- ]?(\d{3})[- ]?(\d{4})$/;
return validNumber.test(str);
}
console.log(`Test Case 01: " ${telephoneCheck("555-555-5555") === true}`);
console.log(`Test Case 02: " ${telephoneCheck("1 555-555-5555") === true}`);
console.log(`Test Case 03: " ${telephoneCheck("1 (555) 555-5555") === true}`);
@i-anshuman
i-anshuman / rot13.js
Created November 14, 2019 16:38
FreeCodeCamp: Caesars Cipher
'use strict';
const rot13 = (str) => {
const decrypted = [...str].map(c => {
let charCode = c.charCodeAt(0);
if (charCode >= 65 && charCode < 78) {
charCode += 13;
}
else if (charCode >= 78 && charCode <= 90) {
charCode -= 13;
@i-anshuman
i-anshuman / toRoman.js
Last active November 14, 2019 16:37
FreeCodeCamp: Roman Numeral Converter
'use strict';
const getRange = (num, list) => {
return [
list.reduce((previous, current) => {
return (previous < num && num < current) ? previous : current;
}),
list.reduce((previous, current) => {
return (previous < num && num < current) ? current : previous;
})