This is an excersize to practise types of variables, functions, etc in Javascript. I am getting an error while runing th

Post Reply
Olsphada
Нов
Нов
Posts: 1
Joined: Wed Jan 13, 2021 8:57 am

This is an excersize to practise types of variables, functions, etc in Javascript. I am getting an error while runing th

Post by Olsphada » Wed Jan 13, 2021 9:48 am

Това е отличен размер за практикуване на типове променливи, функции и т.н. в Javascript. Получавам грешка при управлението на кода и не знам причината, след като прекарах над 2 часа в търсене на отговора.

Може ли да погледнете pls:

Code: Select all

const number = 14;


const string = "yes";
const booleanVar = (10 > 9);
const nullVar = 0;
const undefinedVar = f = 2; var h = undefined

const pi = 3.1415926;
const piPlusOne = pi + 1;
const piMinusOne = pi - 1;
const piDividedByThree = pi / 3;
const piSquared = math.pow(3.1415926,2);
const piRoundedUp = math.floor(pi);
const piRoundedUp = math.ceil(pi);

Math.random(1); 

if (true)
{console.log ("Marco")
if (false) 
console.log ("Polo")
 }
  
}


} else { console.log ("Marco Polo")

}

// Remove _replaceMe_ and assign the variables below using x and y. 
const x = 7.5;
const y = -15;
const isXLessThanY =x<y;
const xMinusY = x-y;
const yDividedByX = ;
const xAsAString = "x";
const YToThePowerOfX = math.pov(x,y);
const yRoundedUp = math.round(y);

//move the console log at the start of the code to greet Evelyn. Do not 
modify anything else. 
let mysteryVar = 'start value';
console.log(mysteryVar);
const name = 'Evelyn';
console.log ('Good morrow');
const greeting2 = 'Farewell';

if (name.length < Math.random()*10) {
  mysteryVar = greeting1 + ', ' + name;
} else {
  mysteryVar = greeting2 + ', ' + name;
}

mysteryVar = null;

// Stretch Task: 
// Research the following string methods: includes, indexOf, slice, 
toUpperCase, toLowerCase
// Using those methods on 'sampleText', correctly remove _replaceMe_ and
assign the following variables.
const sampleText = "Isn't documentation great!";
const trueValue = sampleText.includes('great!');
const falseValue = index.(falseValue);
const fruit ["apple", "cherry", "orange"];
console.log(fruit.slice(0, 1)); 
Димитър

User avatar
anonimen
Web-tourist
Web-tourist
Posts: 1610
Joined: Mon Jun 11, 2012 6:07 pm
Answers: 166
Location: Parse error: unexpected "}" in /home/index.php on line 26

Re: This is an excersize to practise types of variables, functions, etc in Javascript. I am getting an error while runin

Post by anonimen » Thu Jan 14, 2021 9:09 pm

Къде е грешката?

uphero
Потребител
Потребител
Posts: 798
Joined: Mon Feb 20, 2012 12:26 pm
Answers: 35
Location: Казанлък
Contact:

Re: This is an excersize to practise types of variables, functions, etc in Javascript. I am getting an error while runin

Post by uphero » Fri Jan 15, 2021 9:07 am

Заснемане.PNG
You do not have the required permissions to view the files attached to this post.

User avatar
Revelation
Web-tourist
Web-tourist
Posts: 956
Joined: Sun Mar 24, 2013 1:23 pm
Answers: 68

Re: This is an excersize to practise types of variables, functions, etc in Javascript. I am getting an error while runin

Post by Revelation » Sun Jan 17, 2021 12:54 am

Как по-точно учите програмни езици в днешно време? Всичко се учи в пъти по-лесно, а грешка като тази даже конзолата ти казва какво не е наред.

Та какво не е наред в цялата картина?

П.П. Не можа ли да измислиш подобаващо заглавие на български език?

User avatar
deam0n
Web-tourist
Web-tourist
Posts: 3045
Joined: Sat Oct 01, 2005 4:33 pm
Answers: 204
Location: Шопландия
Contact:

Re: This is an excersize to practise types of variables, functions, etc in Javascript. I am getting an error while runin

Post by deam0n » Mon Apr 26, 2021 2:11 pm

Имаш 2 пъти деклариране piRoundUp което е грешно, понеже е декларираш като константа.


Там където е Math.ceil() променливата трябва да се казва piRoundDown, за да е логически правилно :D

Post Reply