You cannot submit this assignment

You need to sign in and enrol to submit exercises.

Assignment 1

3 points

Study the following piece of code and think about the values assigned to number at each step.

var number = 5
number += 1
number *= 3
number += number
number -= 2 * (number - 13)

In the field below, enter the five integers that the variable stores after each line is executed, in order. Enter each number on a line of its own.

2 points

The operators += and *= can also be applied to strings.

Study the following code.

var text = ""
text += "<e--gg#h>ed--"
text += "<h>f#-<h>de"
text *= 3
text += "/135"
play(text)

Side note: In this example, the variable is initialized to the empty string (tyhjä merkkijono), which is a string that contains no characters at all (not even whitespace or punctuation). An empty string literal is written as two double quotation marks with nothing in between. Even though the string is empty, you can use it in string operations such as + and +=, as illustrated above.

What string does the above code pass to the play function? Find out and paste the result here.

Posting submission...

Earned points

0 / 5

Exercise info

Assignment category
Graded
Your submissions
0 / 5
Deadline
Wednesday, 2 October 2024, 18:00
Late submission deadline
Thursday, 2 January 2025, 00:01 (-100%)
Group size
1-2
Total number of submitters
925