Skip to content

Instantly share code, notes, and snippets.

View projektorius96's full-sized avatar
🐢
Turtles do code

LG projektorius96

🐢
Turtles do code
View GitHub Profile
@projektorius96
projektorius96 / nestedFn(2).js
Last active October 25, 2019 11:34
Access nested function content
function init(color) {
function changeBackground() {
document.body.style.background = color;
}
changeBackground();
}
window.addEventListener("click",function() { init('red') });
https://docs.google.com/document/d/[GOOGLE GENERATED FOLDERorFILE ID]/edit?rm=minimal
instead of "?usp=sharing" put "?rm=minimal" without quotation marks after /edit
var myArray = new Array();
function getInterval (start, step, end, ommit){
for (start; start <= end; start+= step) {
// if statement below works as exclusion by ommitting the end i.e. the end is excluded if end === ommit of course
if (start >= ommit) {
continue;
}
myArray.push([start]);
console.dir(myArray);
}
function getInterval (start, step, end, ommit){
for (start; start <= end; start+= step) {
if (start == ommit) {
continue;
if (start > ommit) {
continue;
}
}
var resultArr = [start, step, end, ommit];
[start, step, end, ommit] = resultArr;
function getInterval (start, step, end, ommit){
for (start; start <= end; start+= step) {
if (start == ommit) {
continue;
if (start > ommit) {
continue;
}
}
document.write(start + "<br />");
}
function getInterval (start, step, end, ommit){
for (start; start <= end; start+= step) {
if (start == ommit) {
continue;
if (start > ommit) {
continue;
}
}
document.write(start + "<br />");
}
// simplified interval function
function getInterval (start, step, end, ommit){
for (start; start <= end; start+= step) {
if (start == ommit) {
continue;
if (start > ommit) {
continue;
}
}
document.write(start + "<br />");
/* var str = ""; if string leave as a string */
// var strToNum = ""; syntax "" to [] changed below
var strToNum = [];
rangeLabel:
for (var i = 0; i < 10; i++) { // start at zero i.e. i = 0
if (i === 1 || i === 2) { // define numberOne and numberTwo as the numbers being omitted
continue rangeLabel; // please ommit number One and number Two by using keywoard continue
}
strToNum += i;
@projektorius96
projektorius96 / Increment iterator++ via Array
Last active April 24, 2019 16:27
Manually iterate array via @@iterator method
var NumbersFromOne = {
[Symbol.iterator]: ()=> {
var i = 0;
var myArr = ['myArr', 'is', 'iterable'];
return {
next: ()=> {
if (i < myArr.length) {return { value: myArr[i++], done: false };}
else {{return { value: "THIS MANUAL ITERATION IS DONE (TRUE)", done: true };}
}
}
var NumbersFromOne = {
[Symbol.iterator]: ()=> {
var i = 0;
return {
next: ()=> {
if (i < 11) {return { value: i++, done: false };}
else {{return { value: i++, done: true };}
}
}
};