Category Archives: Javascript (en)

JavaScript – loop with do-while postcondition

In JavaScript, in addition to the while and for loops, there is another variant of the do-while loop: do{ }while(); The meaning of this construct is that what is inside the curly braces is executed first, and then the while() … Continue reading

Posted in Javascript (en) | Leave a comment

JavaScript – while and for loops

JavaScript has two loops, while and for. They both run at the same speed. The for loop is more flexible – it has three parts separated by semicolons in parentheses. General entry: for(first; second; third); Inside the parentheses, the semicolon … Continue reading

Posted in Javascript (en) | Leave a comment

JavaScript – simple tasks for loops

Goal: write JavaScript code that calculates how much 2^10 is using a loop. Solution: varnum=2; varpower=10; varresult=1; var subpower=1 while (subpower<=power){result*=num;subpower++}; document.write(result)

Posted in Javascript (en) | Leave a comment

JavaScript – how to embed code in html and display on the site

JavaScript code can be written in any notepad and saved with a .js extension – you can also embed the code in an html page using the <script>…</script> tags in both the head and body sections. It is better to … Continue reading

Posted in Javascript (en) | Leave a comment

JavaScript – Loops, Counter

A loop is a piece of code that repeats a certain number of times. The number of repetitions or the number of iterations is described with a counter. The loop is written with while(an expression that is converted to a … Continue reading

Posted in Javascript (en) | Leave a comment

JavaScript – data output

Inside the html code, you can insert and execute JavaScript using the <script>…</script> tags, which can be inserted into the head of the page. Data output is different depending on the interpreter: var cat = “vera”; //cat’s name document.write(‘Hi, ‘ … Continue reading

Posted in Javascript (en) | Leave a comment

JavaScript – comments

A comment is a piece of code that is not interpreted. There are multi-line comments and single-line comments. Multiline comment starts with /* and ends with */ JavaScript code /* a comment for a few lines */ JavaScript code A … Continue reading

Posted in Javascript (en) | Leave a comment

JavaScript – good manners

In JavaScript, it is customary to name variables in small letters (if the name is one word) – cat; If the variable name consists of two words, then camel case notation is used, i.e. the first word is written in … Continue reading

Posted in Javascript (en) | Leave a comment

JavaScript – Basic Operators

Comparison operator > / < If we write 2 < 6 , we thus ask the question, is it true or not? The answer can be in the form of boolean values – True / False. true > false Equality … Continue reading

Posted in Javascript (en) | Leave a comment

JavaScript – first impression

Java programming language or Java script – JavaScript – was created by a fun programmer in 10 days. Almost as God created the Earth, so Brendan Eich created a programming language in 1995 that is compatible with all browsers and … Continue reading

Posted in Javascript (en) | Leave a comment