Skip to content

Instantly share code, notes, and snippets.

@rmrotek
rmrotek / removeKey.js
Last active January 16, 2019 17:28
Removes specified key from obj
var user = {
"id": 1,
"name": "Leanne Graham",
"username": "Bret",
"email": "[email protected]",
"address": {
"street": "Kulas Light",
"suite": "Apt. 556",
"city": "Gwenborough",
"zipcode": "92998-3874",
@rmrotek
rmrotek / email.js
Created January 11, 2019 15:23
random code
var emailForm = document.getElementById('emailForm')
function handleForm(event) {
event.preventDefault();
var checkBox = document.getElementById("myCheck");
var myRemind = document.getElementById("remind");
var getEmail = document.getElementById('getEmail');
export const mapObjectToArray = (obj) => (
Object.entries(obj || {})
.map(([key, value]) => (
typeof value === 'object' && !(value instanceof Array) ?
{ ...value, key }
:
{ key, value }
))
)
@rmrotek
rmrotek / validatePIN.js
Created September 17, 2018 20:40
PIN validation
function validatePIN(pin) {
if (pin.match(/^\d{4}$|^\d{6}$/) && (pin.length == 4 || pin.length == 6)){
return true;
}
else {
return false;
}
}
@rmrotek
rmrotek / email_validate.js
Created September 17, 2018 20:33
email validation js
function validateEmail(str) {
if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(str))
{
return (true)
}
return (false)
}