This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

Themabewertung:
  • 0 Bewertung(en) - 0 im Durchschnitt
  • 1
  • 2
  • 3
  • 4
  • 5
Was ist falsch?
#1
const celsius = getRandomInt(100);

Kelvinraten1(prompt('Claus sagt: Wieviel Grad Kelvin sind ' + celsius + ' Grad Celsius?'));
function Kelvinraten1(x) {
  if ( x === celsius + 273.15 ) {
  console.log('Claus sagt: Großartig hast du geraten, bei der 1ten Frage');
} else {
  console.log('Claus sagt: Du hast die richtige Antwort leider verfehlt');

}
 
}
function getRandomInt(max) {
  return Math. floor(Math. random() * max);
}



Ich schreibe das richtige Ergebnis rein aber es geht nicht.
Zitieren
#2
Dein Code ist leider falsch. Alleine die If-Anweisung ist fehlerhaft. Hier solltest du keinen +Operator verwenden. Hier gelten nur Zuweisungsoperatoren oder logische Operatoren. Zudem fragst du mit === auch gleich ab ob Beide vom gleichen Datentyp sind. Der Prompt-Aufruf ist auch fehlerhaft.
"Gerne dürft ihr mir eine gute Bewertung da lassen aber auch gegenüber Kritik bin ich offen" Angel
Als Lösung markieren Zitieren


Gehe zu:


Benutzer, die gerade dieses Thema anschauen: 1 Gast/Gäste