1 -Micro:Bit and JavaScript Assessment #1

 1. The BBC Micro:Bit is a pocket-sized codeable computer. It has ___ red LEDs that can light up, flash messages, create games, and invent digital stories! (1 mark)

 2. Combining the micro:bit with the Espruino firmware allows you to control it using J__________, one of the most popular programming languages on the planet! (1 mark)

 3. What does the following Block code do? (2 marks)

 4. JavaScript 'Apps' are computer programs written as lines of text. Each line of text is made up of one or more statements, which are separated by a (____________) character. (1 mark)

 5. What is the following definition referring to? (1 mark)
A container or a "storage box" for
values that can change as the program
is running. These are often declared
at the start of a program and define
the input.

 6. What could the following block code be used to simulate? (1 mark)

 7. What is the correct term for looping or repetition? (1 mark)

 8. What is it called when the program needs to make a decision? This is a programming construct that begins with 'S'. (1 mark)

 9. Fill in the blanks (yellow blank) with the correct term. (1 mark)

 10. What is the code block for the microbit to display a number? (1 mark)

 11. What is the code block for the microbit to display some text? (1 mark)

 12. Which of these blocks will flash three times? (1 mark)

 13. What does the following bit of code do? (1 mark)

 14. Which of these blocks will flash forever? (1 mark)

 15. What is the name of the variable shown in the code below? (1 mark)

 16. What does the following Micro:Bit Java Script do?(6 marks)

 17. Your school cafeteria has written the following prototype program. What should line 1 be changed to? (1 mark)
let item = 50
input.onGesture(Gesture.Shake, () => {
    item = Math.random(2)
    if (item == 0) {
        basic.showString("You have chosen: Sandwich")}
    else if (item == 1) {
        basic.showString("You have chosen: Jacket Potato")}
    else if (item == 2) {
        basic.showString("You have chosen: Salad")}
    else {
        basic.showString("You have chosen: Pizza")}

 18. Referring to the above program, can you spot another error in the first six lines of the code? (1 mark)

 19. Refer again to the code in question 16. What is missing from the end of the program? (1 mark)

 20. Variables are declared using the ___ keyword and allow us to store data such as text, numbers and objects in the computer's memory using a name of our choosing. (1 mark)

 21. Referring to the excerpt below showing data types that can be used in JavaScript. Fill in the blanks for no. 3. (1 mark)
String - Text data.
Number - Numbers.
______ - True or false values.
Array - Lists of data.
Object - Complex data types

 22. What will the following code display (output) on running the program? (1 mark)
 var myArray = [3,4,5];
   var firstItem = myArray[0];
   alert( "First item: " + firstItem );

 23. The line of code above would set the variable 'splat' to true if the variable 'x' contains a value ________________.(1 mark)
if( x > 1000 ) splat = true;

 24. Refer to the following code. Which image is displayed if the game is NOT over? (1 mark)
if( splat ) 
        imageName = "splat.jpg";
        gameOver = true;
        imageName = "bird.jpg"; 
        gameOver = false;

 25. It is possible to broadcast messages using a BBC Micro:Bit and its Radio function. How do Microbits in a certain group send messages to one another? (1 mark)

 26. The following code -radio.onDataPacketReceived, tells the microbit what to do when a data packet is received. In this case the microbit should expect a __________ and a _________. (2 marks)

 27. Adam has coded the following. From analysing the code below you can deduce that he has ____ possible messages which is why he needs ____ options in his selection (IF) statement (1 mark)

 28. Analyse the code below. radio.sendNumber will send any number between 0 and _____ to the group of Micro:bits. You can specify the number in brackets after sendNumber (1 mark)
input.onButtonPressed(Button.B, () => {    radio.sendNumber(0)})

input.onButtonPressed(Button.AB, () => {    radio.sendNumber(1)})

 29. This code logic allows you to have multiple conditions. Four else-if statements have been used which allows for how many possible options? (1 mark)

 30. Look at the example below. It is possible to code the LED so that the LED is either on or off. The code to turn an LED on is ___. (1 mark)