Variables

I - calculate

In this example, x, y, and z are variables.

II - concatenate sentence

The result of adding "Julia" + " " + "Julia":

III - VAT

VAT Calculator


Amount($):

Conditions

Conditions

II - maximum

IV - day’s number

Loops

Arrays

I print an array

II - maximum

Write an algorithm which receives an array of integers and prints its maximum.

III - minimum

Write an algorithm which receives an array of integers and prints its minimum.

IV - minimum position

Write an algorithm which receives an array of integers and prints the position of its minimum.

The lowest number is .

Functions

Trial by pseudo code

I - list of random numbers

Write a function which returns an array of n random numbers, n being the only received parameter.

function randomArray(n) {
let array = []
for (let i = 0; i < n; i++) {
array.push(Math.floor(Math.random() * Math.floor(1000)))
}
return array
}

II - translate

The main goal of pseudo code is to write down the logic behind an algorithm, so that you can easily translate it into human speech or code. Given the algorithm below - with your word explain its purpose - translate it into Python and Javascript function in_array(element,list_elements) {
boolean exist = false
for I = 0 until length($list_elements) do {
if $element == $list_elements[I] then {
$exist = true
}
}
return $exist
}


This function has two arguments: element and list_elements. The boolean exist is defined as false. The function will look for the "element" in the array till this will be found. Once the element is found, we are receiving the answer "true". Is element is not found, the function returns "false".

Variant 1

function inArray(element, list_elements) {
let exist = false
list_elements.array.forEach(element => {
if (item == element) exist = true
})
console.log(exist);
}

Variant 2

function inArray(element, list_elements) {
let exist = false
for (let i = 0; i < list_elements.length; i++) {
return exist
}

III - sort an array

JavaScript Array Sort

Click the button to sort the array in ascending order.