22 <a href =" /README.md#this-is-a-collection-of-modern-interview-code-challenges-on-javascript-suitable-for " id =" home " >Home</a >
33</div >
44
5- ## JavaScript interview code challenges on Primitives - concepts
6-
7- 1 . [ Show the usage of ` typeof ` operator on different types of values] ( #Q1 )
8- 1 . [ Show the different ways of concatenating numbers and strings] ( #Q2 )
9- 1 . [ Show the conversion from number to string and vice versa] ( #Q3 )
10- 1 . [ Write a code to operate on integer numbers outside the range of numbers in JavaScript] ( #Q4 )
11- 1 . [ Show the usage of ` || ` , ` && ` , ` ?? ` and ` !! ` with code examples] ( #Q5 )
12- 1 . [ Show the frequently and commonly used methods available on ` Number ` object with coding examples] ( #Q6 )
13- 1 . [ Write the polyfill for ` Number.isNaN ` ] ( #Q7 )
14- 1 . [ Show the frequently and commonly used methods available on ` Math ` object with coding examples] ( #Q8 )
15- 1 . [ How can we solve the problem of comparision of 0.1 + 0.2 with 0.3 where ` === ` operator fails] ( #Q9 )
16- 1 . [ Write a code to iterate over a string] ( #Q10 )
17- 1 . [ Show the usage of template literals, expression interpolation and tagged templates] ( #Q11 )
18- 1 . [ Write a code to show the working of ` try...catch...finally ` ] ( #Q12 )
19- 1 . [ Show the creation and usage of ` symbol ` with code] ( #Q13 )
20-
21- ---
22-
23- #### Q1
24- ### Show the usage of ` typeof ` operator on different types of values
5+ <h2 align =" center " >JavaScript interview code challenges on Primitives - concepts</h2 >
6+
7+ <br >
8+
9+ ### Q. Show the usage of ` typeof ` operator on different types of values
2510
2611- The ` typeof ` operator returns a string indicating the type of the operand
2712
@@ -51,8 +36,8 @@ Arrays and functions are sub type of objects
5136
5237<br />
5338
54- #### Q2
55- ### Show the different ways of concatenating numbers and strings
39+
40+ ### Q. Show the different ways of concatenating numbers and strings
5641
5742- Concatenation of strings and numbers is a common practical use case
5843
@@ -81,8 +66,8 @@ Arrays and functions are sub type of objects
8166
8267<br />
8368
84- #### Q3
85- ### Show the conversion from number to string and vice versa
69+
70+ ### Q. Show the conversion from number to string and vice versa
8671
8772- Conversion between numbers and strings is a common practical use case
8873
@@ -112,8 +97,8 @@ If the number is floating, `parseFloat` can be used. `parseInt` and `parseFloat`
11297
11398<br />
11499
115- #### Q4
116- ### Write a code to operate on integer numbers outside the range of numbers in JavaScript
100+
101+ ### Q. Write a code to operate on integer numbers outside the range of numbers in JavaScript
117102
118103- ` BigInt ` is a datatype in JavaScript which facilitates the mathematical opertions on huge value of integer number
119104- It is represented by a suffix 'n' for number value
@@ -135,8 +120,8 @@ The big integers cannot be operated directly with normal number datatype. `10n +
135120
136121<br />
137122
138- #### Q5
139- ### Show the usage of ` || ` , ` && ` , ` ?? ` and ` !! ` with code examples
123+
124+ ### Q. Show the usage of ` || ` , ` && ` , ` ?? ` and ` !! ` with code examples
140125
141126- The __ logical OR__ (||) operator for a set of operands is true if and only if one or more of its operands is true
142127- The __ logical AND__ (&&) operator for a set of operands is true if and only if all of its operands are true
@@ -190,8 +175,8 @@ It is not possible to combine both the AND (&&) and OR operators (||) directly w
190175
191176<br />
192177
193- #### Q6
194- ### Show the frequently and commonly used methods available on ` Number ` object with coding examples
178+
179+ ### Q. Show the frequently and commonly used methods available on ` Number ` object with coding examples
195180
196181- ` isInteger` is used to check if the given number is integer or not
197182- ` parseInt` is used to convert a given value in to integer
@@ -231,8 +216,8 @@ Number.isNaN("text"); // false
231216
232217<br />
233218
234- #### Q7
235- ### Write the polyfill for ` Number .isNaN `
219+
220+ ### Q. Write the polyfill for ` Number .isNaN `
236221
237222- A polyfill is a piece of code used to provide modern functionality on older browsers that do not natively support it
238223- ` NaN ` is the only value which is not equal to itself and hence comparision operator cannot be used directly to check if a value is ` NaN `
@@ -251,8 +236,8 @@ Even though the name says _Not a Number_, it is of type "number"
251236
252237<br />
253238
254- #### Q8
255- ### Show the frequently and commonly used methods available on ` Math ` object with coding examples
239+
240+ ### Q. Show the frequently and commonly used methods available on ` Math ` object with coding examples
256241
257242- ` abs` is used to get the absolute value of the given number
258243- ` floor` is used to get the greatest integer smaller than or equal to the given number
@@ -281,8 +266,8 @@ Math.trunc(-6.3)); // -6
281266
282267<br />
283268
284- #### Q9
285- ### How can we solve the problem of comparision of 0.1 + 0.2 with 0.3 where ` === ` operator fails
269+
270+ ### Q. How can we solve the problem of comparision of 0.1 + 0.2 with 0.3 where ` === ` operator fails
286271
287272- The addition of 0.1 and 0.2 will result in to 0.30000000000000004 and the comparision with 0.3 fails
288273- ` Number .epsilon ` is 2<sup>-52</sup>, which can be used to verify if this decimal values are matching
@@ -296,8 +281,8 @@ Math.trunc(-6.3)); // -6
296281
297282<br />
298283
299- #### Q10
300- ### Write a code to iterate over a string
284+
285+ ### Q. Write a code to iterate over a string
301286
302287- String can be traversed using its string index or value as string can act like an iterable
303288
@@ -328,8 +313,8 @@ for(let value of str){
328313
329314<br />
330315
331- #### Q11
332- ### Show the usage of template literals with expression interpolation and tagged templates
316+
317+ ### Q. Show the usage of template literals with expression interpolation and tagged templates
333318
334319- Template literals are string literals allowing embedded expressions and support multi lines
335320- Template literals are enclosed by the backtick \`
@@ -364,8 +349,8 @@ myTag`Note: ${person} is a member of following communities: ${membership}`;
364349
365350<br />
366351
367- #### Q12
368- ### Write a code to show the working of ` try ... catch... finally`
352+
353+ ### Q. Write a code to show the working of ` try ... catch... finally`
369354
370355- The ` try ` statement consists of a try-block, which contains one or more statements. At least one catch-block, or a finally-block, must be present
371356- The exceptions and errors from try block are caught in catch block
@@ -391,8 +376,8 @@ try {
391376
392377<br />
393378
394- #### Q13
395- ### Show the creation and usage of ` symbol` with code
379+
380+ ### Q. Show the creation and usage of ` symbol` with code
396381
397382- A "symbol" represents a unique identifier
398383- ` Symbol .for ` method searches for existing symbols in a runtime-wide symbol registry returns the same. If not found, creates a new Symbol
0 commit comments