Please paste your errors as comments into this gist. Paste both your code and the error message.
Created
December 22, 2016 18:53
-
-
Save airportyh/05452978247e322d8df6fc232d90a228 to your computer and use it in GitHub Desktop.
var belowFourMil = true;
var a = 1;
var b = 2;
var sum = 0;
var temp = 0;
while(belowFourMil){
//a, b, temp
var temp = a + b;
a = b; // set previous to recent
b = temp; //Set recent to the new number
/ need to check if temp id divisible by 2
if(temp % 2 === 0){
sum += temp;
}
if(temp > 4000000){
belowFourMil = false;
}
}
console.log(sum);
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
var arr;
console.log(arr.length);
Uncaught TypeError: Cannot read property 'length' of undefined
at sort-alg.html:80
scripts.js:80 Uncaught SyntaxError: Unexpected token else
if(stock.Change.indexOf('+') > -1 )
var classChange = "success";
}else{
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);
Author
person.friends[0].name.length
// __ __
// | \\\ /__\
// |.\\\ \ //--.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);
}
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
Uncaught SyntaxError: Invalid regular expression: missing / fib1.html:26