w3resource

JavaScript - Exercises, Practice, Solution

What is JavaScript?

JavaScript is a cross-platform, object-oriented scripting language. It is a small and lightweight language. Inside a host environment ( a web browser), JavaScript can be connected to the objects of its environment to provide programmatic control over them.

JavaScript contains a standard library of objects, such as Array, Date, and Math, and a core set of language elements such as operators, control structures, and statements. Core JavaScript can be extended for a variety of purposes by supplementing it with additional objects.

The best way we learn anything is by practice and exercise questions. We have started this section for those (beginner to intermediate) who are familiar with JavaScript. Hope, these exercises help you to improve your JavaScript coding skills. Currently following sections are available, we are working hard to add more exercises. Happy Coding!

List of JavaScript Exercises :

More to Come !

Popularity of Programming Language
Worldwide, Jun 2022 compared to a year ago:

`
Rank Change Language Share Trend
1 Python 27.61 % -2.8 %
2 Java 17.64 % -0.7 %
3 Javascript 9.21 % +0.4 %
4 C# 7.79 % +0.8%
5 C/C++ 7.01 % +0.4 %
6 PHP 5.27 % -1.0 %
7 R 4.26 % +0.5 %
8 up arrow TypeScript 2.43 % +0.7 %
9 down arrow Objective-C 2.21 % +0.1 %
10 down arrow Swift 2.17 % +0.4 %
11 up arrow Matlab1.71% +0.2 %
12 down arrow Kotlin 1.57 % -0.2 %
13 Go 1.48 % +0.0 %
14 up arrow Rust 1.29 % +0.4 %
15 Ruby 1.1 % -0.0%
16 down arrow VBA 1.07 % -0.2 %
17 up arrow Ada 0.95 % +0.4 %
18 up arrow Scala 0.73 % +0.2 %
19 down arrow Visual Basic 0.65 % -0.0 %
20 down arrow Dart 0.64 % +0.0 %
21 up arrow Abap 0.58 % +0.1 %
22 down arrow Lua 0.51 % -0.0 %
23 up arrow Groovy 0.48 % +0.1 %
24 down arrow Perl 0.44 % +0.0 %
25 Julia 0.41 % +0.0 %
26 Cobol 0.34 % +0.1 %
27 Haskell 0.29 % +0.1 %
28 Delphi/Pascal 0.16 % +0.1 %

Source : https://pypl.github.io/PYPL.html

TIOBE Index for June 2022

June 2022 June 2021 Change Programming Language Ratings Change
1 2 up arrow Python 12.20% +0.35%
2 1 down arrow C 11.91% -0.64%
3 3 Java 10.47% -1.07%
4 4 C++ 9.63% +2.26%
5 5 C# 6.12% +1.79%
6 6 Visual Basic 5.42% +1.40%
7 7 JavaScript 2.09% -0.24%
8 10 up arrow SQL 1.94% +0.06%
9 9 Assembly language 1.85% -0.21%
10 16 up arrow Swift 1.55% +0.44%
11 11 Classic Visual Basic 1.33% -0.40%
12 18 up arrow Delphi/Object Pascal 1.32% +0.26%
13 8 down arrow PHP 1.25% -0.97%
14 23 up arrow Objective-C 1.02% +0.33%
15 20 up arrow Go 1.02% +0.07%
16 14 down arrow R 0.98% -0.22%
17 15 down arrow Perl 0.76% -0.41%
18 38 up arrow Lua 0.76% +0.43%
19 13 down arrow Ruby 0.75% -0.48%
20 26 up arrow Prolog 0.74% +0.18%

Source : https://www.tiobe.com/tiobe-index/

Do not submit any solution of the above exercises at here, if you want to contribute go to the appropriate exercise page.

Note : Since JavaScript is a loosely-typed, dynamic and expressive language, you may accomplish the same task in various ways. Therefore the ways (solution of the exercises) described here are not the only ways to do stuff. Rather, it would be great, if this helps you anyway to choose your own methods.

[ Want to contribute to JavaScript exercises? Send your code (attached with a .zip file) to us at w3resource[at]yahoo[dot]com. Please avoid copyrighted materials.]



JavaScript: Tips of the Day

Returns true if the given number is a power of 2, false otherwise

Example:

const tips_isPowerOfTwo = n => !!n && (n & (n - 1)) == 0;
console.log(tips_isPowerOfTwo(0)); 
console.log(tips_isPowerOfTwo(4));
console.log(tips_isPowerOfTwo(16));

Output:

false
true
true