Let's dive in and see a variable in the wild. Here is how you declare a constant variable:
const myName = 'Arya';
console.log(myName);
// Output: Arya
Let's consider the above example:
// Closures will blow your mind or make you pull your hair out! | |
// One of the most difficult topics is that of closures. | |
// So I will write a small function that returns a function | |
// that calculates how many years we have left to retirement. | |
// retirementAge passes the age someone has to have | |
// in order to retire | |
function retirement(retirementAge) { | |
var a = ' years left until retirement.'; |
// immediately invoked function expression | |
// its an anonymous function wrapped in parentheses | |
// Step 1: JS Runtime executes this line and this anonymous | |
// function is declared and immediately called because | |
// of (); operator below. | |
var budgetController = (function() { | |
// Step 2: Then this is declared and it returns an | |
// object below it. | |
// this part of the code is private | |
var x = 23; |
Of all the computer languages you will read about on my blog, HTML (hypertext markup language) is the simplest. That's because it's not a full fledged programming language. You can't write logical statements using HTML like you can with a programming language like Javascript (where, for instance, you can have code that behaves one way if some condition is true, and another if that condition is false). Instead, HTML is used to mark up content so web browsers know what kinds of content they're dealing with.
For instance, you can use an <h2>
tag to tell the browser to render the word "Skills" as a heading, and you can use an unordered list with list items (<ul>
and <li>
s) to mark up the skills themselves and render them as a bulleted list.
For the most part, that's all there is to HTML: you take content and wrap it in the appropriate tags. You'll get plenty of practice with that throughout your projects, but in the remainder of this reading, I will go over enough background about HTML to code
q = gets.strip.to_i | |
for a0 in (0..q-1) | |
s = gets.strip | |
# your code goes here | |
# hackerrank | |
word = "" | |
index = 0 | |
s.each_char do |c| | |
if c == "hackerrank"[index] | |
word += c |
function main() { | |
var n = parseInt(readLine()); | |
for (i = 1; i <=n; i++){ | |
line = Array(n).fill(' '); | |
for (j = 0; j < i; j++){ | |
line[j] = '#'; | |
} | |
console.log(line.reverse().join('')) | |
} |
function main() { | |
var n = parseInt(readLine()); | |
arr = readLine().split(' '); | |
arr = arr.map(Number); | |
let positive = negative = zero = 0; | |
for (i =0; i < n; i++){ | |
let current = arr[i]; | |
if (current > 0) { | |
positive += 1; |
function main() { | |
var n = parseInt(readLine()); | |
var a = []; | |
for(a_i = 0; a_i < n; a_i++){ | |
a[a_i] = readLine().split(' '); | |
a[a_i] = a[a_i].map(Number); | |
} | |
let sumPrimaryDiagonal = sumSecondaryDiagonal = 0; | |
function main() { | |
var S = readLine(); | |
const expectedSignal = 'SOS'; | |
let errorCount = 0; | |
for (i = 0, len = S.length; i <len; i += 3) { | |
const currentSignal = S.slice(i, i + 3); | |
if (currentSignal === expectedSignal) continue; | |
if (currentSignal[0] !== expectedSignal[0]) errorCount += 1; | |
if (currentSignal[1] !== expectedSignal[1]) errorCount += 1; |
process.stdin.resume(); | |
process.stdin.setEncoding('ascii'); | |
var input_stdin = ""; | |
var input_stdin_array = ""; | |
var input_currentline = 0; | |
process.stdin.on('data', function (data) { | |
input_stdin += data; | |
}); |