Conditional statements self assesment quiz

Beschreibung

Junior Certificate Web Developing (JavaScript) Quiz am Conditional statements self assesment quiz, erstellt von Kostas Diakogiannis am 06/09/2018.
Kostas Diakogiannis
Quiz von Kostas Diakogiannis, aktualisiert more than 1 year ago
Kostas Diakogiannis
Erstellt von Kostas Diakogiannis vor etwa 6 Jahre
6
0

Zusammenfassung der Ressource

Frage 1

Frage
Which of the following values evaluate eventually to false?
Antworten
  • 22
  • 0
  • 'undefined'
  • !false

Frage 2

Frage
What does the following code produce as a message? var numOfChoice = 3; switch(numOfChoice) { case 1: console.log(`You have selected ${numOfChoice}'); break; case 2: console.log(`You have selected ${numOfChoice}'); break; case 3: console.log(`You have selected ${numOfChoice}'); default: console.log(`You have selected nothing!');
Antworten
  • You have selected 3
  • You have selected nothing!
  • error! A break keyword is missing.
  • You have selected 3 You have selected nothing!

Frage 3

Frage
When is it appropriate to use a switch-case syntax in favor of if-else statements?
Antworten
  • There is no case at all, if else syntax is more precise and less error prone.
  • When we want to check multiple times if a variable holds a specific value.
  • In any case. Switch cases provide a better and cleaner syntax to work with.
  • In case we want to compare a variable if is greater or lower than a specific value.

Frage 4

Frage
What does the following code produce as a message to console? var choice = 5; if (choice == 2) { console.log(2); } else { console.log(choice); }else if (choice == 5) { console.log('You have selected 5 pieces'); }
Antworten
  • 2
  • You have selected 5 pieces.
  • The number of your choice.
  • Syntax error.

Frage 5

Frage
Imagine we are having 10 numbers from 1 to 10. 1, 2, 3, 4, 5, 6, 7, ,8 ,9, 10. For everyone of these numbers we run the following statement: if (num % 2 !== 0 ) { // Do something here } Under which numbers will this condition be executed?
Antworten
  • none
  • all
  • 2, 4, 6, 8, 10
  • 1, 3, 5, 7, 9

Frage 6

Frage
Given that we have these variables: var money = 2; var drink = 5; var inMood = true; var freeTime = true; if (money - drink > 0 || !inMood && freetime) { console.log('Go out for a drink'); } else { console.log('Stay in'); } Will i go for a drink or what?
Antworten
  • Of course i do. Party animal rules.
  • Nope. Misery at it's best.

Frage 7

Frage
What is the outcome of this statement? var playFootball = true; !playFootball ? console.log('I told you, you can't play today!') : console.log('Play freely without fear');
Antworten
  • I told you, you can't play today!
  • Play freely without fear

Frage 8

Frage
Select one of the following statements that is wrong.
Antworten
  • In if else statements, it is a good practice to check the more unique condition first and then the more general.
  • There is no limit to how many 'if else' statements we can put as alternatives to an if block.
  • Default option is mandatory inside a switch case block.
  • 'Else' statement is mandatory as alternative to an 'if' block.
Zusammenfassung anzeigen Zusammenfassung ausblenden

ähnlicher Inhalt

Quiz - Object Oriented Javascript
arunram.krish
Examen Fundamentos Basicos de Programación
Jose Valderrama0721
Test I. Introduction to web technologies
Angel Martínez Rodriguez
JavaScript Fundamentals
Andrew Watters
Front-End Web Development
Chanthy Ngin
Javascript - Quiz - Jan 2016
arunram.krish
OpenSource Programming
Faheem Ahmed
Javascript basics
James Drummond
jQuery Basics functions and method
Victor Bini
Javascript Variables
Rene Escobar
JavaScript DOM API - Funções Basicas - Interactive Web Pages
Victor Bini