-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjavascript.html
2007 lines (2007 loc) · 139 KB
/
javascript.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!-- wp:heading {"canvasClassName":"cnvs-block-core-heading-1686125278519"} -->
<h2 class="wp-block-heading">OPERATOR, INPUT, OUTPUT</h2>
<!-- /wp:heading -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>Comments in Javascript</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>// Comment something</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>Multiline comments</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>/*Text xzy*/</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>Declare and assign string (possible with "" or '') - "var" was the earlier version in the past for that</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>let intStr = "7"</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>Linebreak and Tab should not used - is morely css-stuff for formating</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>"/n /t"</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>Declare a variable and assign int (also signed int like -36)</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>let age = 24</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>Defining without assigning (var gets value undefined)</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>let var</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>Define 2 variables (one without value and one with value)</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>let var, age = 25</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>Define and assign 3 variables (a=5, b=8, c=12)</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>let [a, b, c] = [5, 8, 12]</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>Declare a constant and assign int (constant can not be changed like variables)</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>const age = 25</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>Declare and assign float (also signed float like +4.5763</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>let float = 5.14876</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>Change String to Int with base 10</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>let intNum = parseInt(intStr,10);</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>Declare and assign string</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>let floatStr = "5.14673"</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>Change String to Float</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>let floatNum = parseFloat(floatStr);</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>Defines+Assigns a variable (if user exists/has a value use that - otherwise initialize with "guest"</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>let v = user || "guest"</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>Open windows for entering something and store in const inp</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>const inp = prompt("Enter:")</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>Convert numeric value to string</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>num.toString()</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>2nd method to convert numeric value to string</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>num + ""</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>3rd method to convert number / int to a String</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>String(n)</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>Converts String to Number / Int</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>Number(s)</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>Shows the type of the variable as string (eg. "number", "string", "boolean")</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>typeof (x)</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>Modulo / Rest of the division (=> 1)</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>7 % 2</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>Check 2 values / variables (result in true / false)</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>x == y</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>Equal value and equal type</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>x === y</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>Not equal</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>x != y</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>Not equal value and not equal type</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>x !== y</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>Greater, lesser, greater + equal , lesser + equal</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>>,<,>=,<=</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>Check if value is NaN (NotANumber) - eg. when converting with Number() and the value is no number</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>isNaN(x)</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>Check if n is a integer</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>Number.isInteger(n)</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>Makes variable +1</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>num++;</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>Outputs variable num in console</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>console.log(num)</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>Outputs element as table (eg. for objects, arrays)</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>console.table(object)</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>Alert information in a window</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>alert("Text!")</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>Alert some text with outputing the variable "name" between (using backticks "`"</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>alert(`Bla ${name} bla`)</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>Round to 2 decimal digits</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>n = n.toFixed(2)</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>Swap 2 variables</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>[x, y] = [y, x]</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>Exit javascript node program</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>process.exit(1)</code></pre>
<!-- /wp:code -->
<!-- wp:heading {"canvasClassName":"cnvs-block-core-heading-1686125278519"} -->
<h2 class="wp-block-heading">STRING</h2>
<!-- /wp:heading -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>Define a string</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>let s = "this is a test"</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>String with linebreak \n</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>let s = "this \n text"</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>extract only the first character</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>s.slice(0,1)</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>last char of a string</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>s.slice(-1)</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>slicing 2 chars from pos 3 and 4</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>s.slice[3,5]</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>slice from pos 3 to the end</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>s.slice[3]</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>shows the length of the string</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>s.length</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>Lowercase the whole string</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>s = s.toLowerCase()</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>Uppercase the whole string</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>s = s.toUpperCase()</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>Returns the second char of a string</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>s.charAt(1)</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>Search if "xyz" is int the string - returns the position where found - when not found returns -1</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>s.search("xyz")</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>Check if string/chars are in</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>s.includes("ee")</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>Replace "abc" with "xyz" for any occurrences in the string (only working for new browsers!)</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>sNew = s.replaceAll("abc","xyy)</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>2nd method for replacing everything (works for more browsers!)</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>sNew = s.replace(/abc/g,"xyz")</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>Concatenate 2 strings</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>sNew = s1.concat(s2)</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>Delete all whitespaces at the beginning and the end</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>s.trim()</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>Repeat string 3 times</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>s.repeat(3)</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>Split the words in a array</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>s.split(" ")</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>Delete all whitespaces at the beginning and the end</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>s.trim()</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>Fills leading zero in a string with allways 3 chars - eg. 006</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>s.padstart(3,"0")</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>Find Index of first occurence of this string</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>s.indexOf("ee")</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>Outputs the x character in the string => second char of the string (same as s[1])</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>s.charAt(1)</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>Get the last 3 chars of the string</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>s.slice(-3)</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>2nd variant: Get the last 3 chars of the string</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>s.substr(s.length-3)</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>Return Ascii-Code of the first character of the string</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>s.charCodeAt(0)</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>Returns True if the string end with "?"</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>s.endsWith("?")</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>Returns char for specific ascii-code</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>char = String.fromCharCode(65)</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>Check if char is in A-Z</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>char.match(/[A-Z]i)</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>Spread-Operator for string (=> build array with each character)</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>[...s]</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>Convert object-element to string</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>s = JSON.stringify(obj)</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>Convert datetime-object to string in format "yyyy-mm-dd"</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>calcDate.toISOString().split('T')[0]</code></pre>
<!-- /wp:code -->
<!-- wp:heading {"canvasClassName":"cnvs-block-core-heading-1686125278519"} -->
<h2 class="wp-block-heading">ARRAY</h2>
<!-- /wp:heading -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>Define an array</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>let arr = [];</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>Define an array and initialize it</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>let arr = [6,7,8];</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>Define multidim array</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>let mat= [[1,2,3],[4,5,6],[7,8,9]]</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>Get second element => 7</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>arr[1]</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>Access last element in array</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>arr[arr.length-1]</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>Get element in the matrix => 5</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>mat[1][1]</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>Replace the third element</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>arr[2] = 9</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>Returns list as a string => "6,7,8"</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>String(Arr)</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>Must allways be compared with triple = (only == would be wrong)</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>a1 === a2</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>Total count of the elemets in the array</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>arr.length</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>Extracts and delete element at the end (fast!)</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>arr.pop()</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>Extracts and delete element at the begin (slow!)</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>arr.shift()</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>Append new elements to the array at the end (fast!)</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>arr.push("X","Y")</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>Add new elements to the array at the beginning (slow!)</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>arr.unshift("Y","Z")</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>Copy elements from index 2 to index 3 => result is one char at index 2</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>ergArr = arr.slice(2,3)</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>Copy the last 2 elements of the array</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>ergArr = arr.slice(-2)</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>Delete 1 element beginning from index 2</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>arr.splice(2,1)</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>Delete 2 elements beginning from the index 0 - and insert the elements 10 and 11</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>arr.splice(0,2,10,11)</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>From index -1 delete 0 elements and add 3 and 4</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>arr.splice(-1,0,3,4)</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>Delete 2 elements beginning from the index 0 - and assign them to ergArr</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>ergArr = arr.splice(0,2)</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>x > 0) => Return true if all elements are bigger than 0</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>arr.every(x</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>Concatenate 2 arrays to one</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>ergArr = arr1.concat(arr2)</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>Returns first index position of element "xyz" (if not exists result is -1)</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>arr.indexOf("xyz")</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>Return the last index position of the element "xyz"</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>arr.lastIndexOf("xyz")</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>Check if string exists in the array</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>arr.includes("xyz")</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>Reverse the entire array</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>arr.reverse()</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>Split the words in a array</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>arr = varStr.split(" ")</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>Join the elements from the array in a string with ", " as seperator</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>varStr = arr.join(", ")</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>Check if object is an array (if array = true)</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>Array.isArray(arr)</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>Iterate through index of the array</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>for (let i=0; i < arr.lenth; i++) {do smth.}</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>Iterate through array elements</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>for (let elem of arr) {alert(arr)}</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>Convert a node-list to an array</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>arr=Array.from(document.querySelectorAll("a"))</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>2nd method for converting node-list to an array</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>arr=[...document.querySelectorAll("a")]</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>Concatenate the array to a string seperated by " "</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>arr.join(" ")</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>a > b ? 1 : -1) => Order array ascending</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>arr.sort((a,b)</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>a > b ? -1 : 1) => Order array descending</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>arr.sort((a,b)</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>Ordering long method with function</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>arr.sort(function(a,b) {return a > b ? 1 : -1}</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>Find max value in an array with spread operator</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>Math.max(...arr)</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>Find min value in an array with spread operator</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>Math.min(...arr)</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>Array Destrucuring Expl1 (a will be "Ha" and b will be "Ho"</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>let [a,b] = ["Ha","Ho","Hi","He"]</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>Array Destrucuring Expl2 (a will be "Ha" and d will be "He"</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>let [a,,,d] = ["Ha","Ho","Hi","He"]</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>Array Destrucuring Expl3 (a will be "Ha" and rest will be ["Ho","Hi","He"]</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>let [a,...rest] = ["Ha","Ho","Hi","He"]</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>Swapping values (a will be b and b will be a)</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>[a,b] = [b,a]</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>Iterate trough array by index and element (with shortform)<br><br>Outputs index and Outputs element of array<br>(return is not working here - forEach loops are allways running for all elements)</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>arr.forEach((elem,idx) => {<br> console.log(idx)<br> console.log(elem)<br>})</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>Iterate through array by elements and index (with longform)<br><br>Outputs index and Outputs element of array<br>(return is not working here - forEach loops are allways running for all elements)</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>arr.forEach(function(elem,idx) {<br> console.log(idx)<br> console.log(elem)<br>})</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>Iterate trough an array with 1sec pause at every element</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>names.forEach((name, i) => {<br> setTimeout(() => {<br> display(name);<br> }, i * 1000);<br>});</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>Map Method - Short Method (Maps a functionality to all elements of the array - every element multiplicated by 2)</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code> let newarr = arr.map(x => x * 2);</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>Map Method - Long Method (for more code)</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code> let newarr = arr.map (function(x) {<br> x = x * 2<br> }</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>Filter Method - Long Method (Filters all values which are > 6 eg. in a new array)</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>let newarr = arr.filter (function(x){<br> if (x > 6) {<br> return true<br> }<br>})</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>Filter Method - Short Method in one line</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>let newarr = arr.filter(x => x > 6);</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>Reduce Method - for doing something with the array and output / calculate something<br>"total" is the new calculation element - result of this is the sum of all elements of the array<br>every element is added to total - 0 is the default value of "total"</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>erg = arr.reduce ((total, elem) => {<br> return total + elem<br>},0)</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>FindIndex Method - find the index-location of an element in the array (if nothing is found it returns -1)</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>let idx = arr.findIndex(x => {<br> return x < 10;<br>})<br></code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>Some Method - checks whether at least one element in the array passes the test - returns boolean answer<br>1st line defines the check function - 2nd line checks the array with the function</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>const even = (element) => element % 2 === 0;<br>arr.some(even)</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>Every Method - checks whether all elements in the array passed the test by the defined function - return boolean answer<br>1st line defines the check function - 2nd line checks the array with the function</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>const isLower = (elem) => elem < 40;<br>arr.every(isLower)</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>example for a setTimeout<br>the first and second message will appear immediately - the middle message only after 2 seconds</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>console.log('First message!');<br>setTimeout(() => {<br> console.log('This message will always run last...');<br>}, 2000);<br>console.log('Second message!');</code></pre>
<!-- /wp:code -->
<!-- wp:heading {"canvasClassName":"cnvs-block-core-heading-1686125278519"} -->
<h2 class="wp-block-heading">CONTROL STRUCTURE AND ITERATION</h2>
<!-- /wp:heading -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p></p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>if (condition is true) {<br> =>Do something<br>}else if (condition is true){<br> =>Do something else<br>}else{<br> =>Default else<br>}</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>If structure with logical and</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>if (a == 9) && (b == 7) { c = "Hurra!" }</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>If structure with logical or</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>if (a == 9) || (b == 7) { c = "Hurra!" }</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>If structure with logical not</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>if !(a > 13)</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p></p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>switch (expression) { // Switch expression for multiple options<br>case value1: case value 4 // Do something when expression is value1 or value4<br> // Do something<br> break; // Break necessary for any case / value<br>case value2: // Do something when expression is value2<br> // Do something<br> break;<br>default: // When no case is mathing - then do this<br> => Do something<br> break;<br>}</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>Iteration from 1 to 5 with for-loop</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>for (let i=1; i<=5; i++) {}</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>Iteration backwards from 3 to 0 with for-loop</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>for (let i=3; i>=0; i--) {}</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>Iterate through an array</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>for (let i=0; i<arr.length; i++) {}</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>Iterate through a string</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>for (let char of text) {}</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>Iterate through the keys of an object</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>for (let key in obj) {}</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>For loop with pause at any iteration</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>for (let i = 0; i < 5; i++) {<br> setTimeout(() => { // Pause at any iteration for 5 seconds / 5000 ms<br> console.log("hey");<br> }, i * 5000);<br>}</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>While loop with break condition</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>while (x < 4) {<br> if xyz === "abc" {break}<br>}</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>Do While loop with break condition</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>do {} while (x < 4)</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>Endless while loop - has to be exited somewhere</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>while (true) {}</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>Iterate through array by elements (x)</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>arr.forEach((x) => {<br> console.log(x)<br>})</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>Are all falsy values - can checked with if (xyz)...</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>0,"",'',null,undefined,NaN</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>Ternary Operator for if - if isNight=true then s=Night - else s=Day</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>isNight ? s="Night" : s="Day"</code></pre>
<!-- /wp:code -->
<!-- wp:heading {"canvasClassName":"cnvs-block-core-heading-1686125278519"} -->
<h2 class="wp-block-heading">FUNCTION</h2>
<!-- /wp:heading -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>Normal Function Decleration</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>function addFunc(x=0,y=0) { // Define a function - with default value 0 if no input is given<br> let erg = x+y // Calculate erg<br> return erg} // Return erg value<br>addFunc(3,5) // Function Call</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>Function Expression (used for anonymous functions)</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>const add = function(x,y) {...} // Define a function expression (function is assigned to an variable<br>add(3,5) // Function Call</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>Anonymous Function with Fat Arrow syntax</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>const add = (x,y) => {...}<br>add(3,5) // Function Call<br>let h = a => a % 3 // Even shorter without parentees</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>return-statement with "?" or "||"</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>return (age > 18) ? true : console.log('Did parents allow'); // When age > 18 returns true - otherwise output something in the console<br>return (age > 18) || console.log('Did parents allow'); // Same logic with "||"</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>Use Rest Parameters to accept any number of arguments</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>function max(...numbers) { // Any numbers of arguments<br> => do something with a loop<br>}</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>AddEventListener with parameters in the function</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>document.querySelector("#dayToday").addEventListener("click",function() { // define addEventListener as normal but use "function ()"<br> toggleBackground("today", 6) // call the function with parameters inside<br>}, false);</code></pre>
<!-- /wp:code -->
<!-- wp:heading {"canvasClassName":"cnvs-block-core-heading-1686125278519"} -->
<h2 class="wp-block-heading">OBJECT</h2>
<!-- /wp:heading -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>Define an object (literal syntax)</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>let obj = {}</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>2nd method to define object (construtor syntax)</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>let obj = new Object()</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>properties = attributes of the object (eg. color, shape, minutes, seconds)<br><br>Define an object and initialize it</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>let obj = {<br> name: "John",<br> age: 30, // last "," i allowed and called trailing / hanging (its easier so to add/remove/move properties of the object)<br> shout() { // Defines a method for the object<br> return "Hurra!"<br> }<br>}</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>Access property / shows value of the key "name" (1st method) => John (dot.notation)</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>obj.name</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>Shows value of the key "name" (2nd method) => John (bracket notation)</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>obj["name"]</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>Shows key "age" of the object => 30 (dot notation)</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>obj.age</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>Add a new propertie to the object</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>obj.newOne = "xyz"</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>Add a new method to the object</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>obj.newMethod = function(var) {...do someth...}</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>Call the new method</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>obj.newMethod(25)</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>Check if key is in the object</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>age in obj</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>Delete a property of an object (dot notation)</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>delete obj.age</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>Delete a property of an object (bracket notation)</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>delete obj["age nr"]</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>Check if a property / method is in an object</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>if ("property" in obj) {...}</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>Read the keys of an object into an array</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>arr = Object.keys(obj)</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>Read the values of an object into an array</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>arr = Object.values(obj)</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>Read alle key / value pairs of an object into an (nested) array</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>arr = Object.entries(obj)</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>Check if xyz i part of the object</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>obj.hasOwnProperty("xyz")</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>Check if Object is empty</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->
<pre class="wp-block-code"><code>Object.keys(obj).length === 0 && obj.constructor === Object</code></pre>
<!-- /wp:code -->
<!-- wp:paragraph {"canvasClassName":"cnvs-block-core-paragraph-1686132588595"} -->
<p>Iterate through the keys of the object and outputs key and value</p>
<!-- /wp:paragraph -->
<!-- wp:code {"canvasClassName":"cnvs-block-core-code-1686132588597"} -->