Skip to content

Instantly share code, notes, and snippets.

@airportyh
Created December 22, 2016 18:53
Show Gist options
  • Select an option

  • Save airportyh/05452978247e322d8df6fc232d90a228 to your computer and use it in GitHub Desktop.

Select an option

Save airportyh/05452978247e322d8df6fc232d90a228 to your computer and use it in GitHub Desktop.

Please paste your errors as comments into this gist. Paste both your code and the error message.

@annasedlar

Copy link
Copy Markdown

var a = 10;
function makeError(){
for(var i=0; i<=a; i++){
a.push(i);
}
}

makeError();

TypeError: a.push is not a function
at makeError:26:7
at eval:30:1
at eval

@AndyTuttle12

AndyTuttle12 commented Dec 22, 2016

Copy link
Copy Markdown
var arr;
console.log(arr.length);

Uncaught TypeError: Cannot read property 'length' of undefined
at sort-alg.html:80

@ambercoding

ambercoding commented Dec 22, 2016

Copy link
Copy Markdown

scripts.js:80 Uncaught SyntaxError: Unexpected token else

if(stock.Change.indexOf('+') > -1 )
		var classChange = "success";
	}else{

@elizabethgulsby

elizabethgulsby commented Dec 22, 2016

Copy link
Copy Markdown

Uncaught TypeError: i is not a function(…)

function factorial(n) {
var total = 0;
var formula = '';
  for (var i = n; i >= 1; i--) {
    total = total + i;
    if (formula === '') {
      formula = i.toString();
    }
    else {
      formula = formula + '+' + i();
    }
    console.log(formula);
  }
  console.log(total);
}

factorial(3);

@airportyh

Copy link
Copy Markdown
Author
person.friends[0].name.length

@masonmahaffey

Copy link
Copy Markdown
//           __                    __
 //          | \\\                 /__\
 //         |.\\\ \               //--.i
 //         i \\\\ \             ///// i
 //         i \\\\\ \  _______  //////:|
 //         i.\\\\\\ --|i | i|-- /////.|
 //         |:\\\\  |||:i i iiii|  /// i
 //         \ \     / i|i | |||i\      i
 //         /       :| || i i| i       i
 //         |       |:  i | | |i|      \
 //         i        | || | i  i|       i
 //        |      /     | : |     \\    i
 //        |     //  __  :.:: __   \    i
 //        |        / _\     / _\       i
 //        |       | # \      # \       i
 //        i  ___--| \_)      \_)--___  |
 //        i====    \__/     \__/   ====|
 //        i==                        ==|
 //        i-            _-_           -i
 //       /|             \ /            i
 //     //  \    _ _ ---  | -- _       /
 //    /    _\- -   _--   |  --_ --_  /
 //   /    -  \_ _-  _-   |  --  -_  /_
 //    /     _ -\_ -- -__/ \__- -_ _/_ -
 // //      -   _---__  \___/ --__/_  -
 //           _-                    -_




console.time('countPrimes');
countPrimes(2000000);
console.timeEnd('countPrimes');


function countPrimes(num) {

	var knownPrimes = [2,3,5];
	var sum = 0;

	for (var i = 6; i < num; i++) {
		if((i % 2 != 0) && (i % 3 != 0) && (i % 5 != 0)) {
			for (var j = 0; j < knownPrimes.length; j++) {

				if (i % knownPrimes[j] == 0) {
					beak;
				}
				if ((j == (knownPrimes.length - 1) ) && (i % knownPrimes[j] != 0)) {
					knownPrimes.push(i);
				}	
			}
		}
	}

	sum = knownPrimes.reduce(function(a,b){
		return a + b;
	},0);

	console.log(sum);

}







@masonmahaffey

masonmahaffey commented Dec 22, 2016

Copy link
Copy Markdown

X - Uncaught SyntaxError: Unexpected identifier script.js:2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment