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

Olsphada

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

Може ли да погледнете pls:
Код:
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));
 
Как по-точно учите програмни езици в днешно време? Всичко се учи в пъти по-лесно, а грешка като тази даже конзолата ти казва какво не е наред.

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

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


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

Горе