From 6ca18b77d7120cadc1d062146f17987b232fa875 Mon Sep 17 00:00:00 2001 From: Ariel Date: Sat, 7 Jun 2025 18:18:12 -0600 Subject: [PATCH 1/4] Create fromCharCode.md --- .../terms/fromCharCode/fromCharCode.md | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 content/javascript/concepts/strings/terms/fromCharCode/fromCharCode.md diff --git a/content/javascript/concepts/strings/terms/fromCharCode/fromCharCode.md b/content/javascript/concepts/strings/terms/fromCharCode/fromCharCode.md new file mode 100644 index 00000000000..79b402dde16 --- /dev/null +++ b/content/javascript/concepts/strings/terms/fromCharCode/fromCharCode.md @@ -0,0 +1,46 @@ +--- +Title: 'fromCharCode' +Description: 'Its a static method that returns a string created from the specified sequence of UTF-16 code units.' +Subjects: + - 'Web Development' +Tags: + - 'Strings' + - 'Characters' + - 'JavaScript' + - 'Methods' +CatalogContent: + - 'paths/front-end-engineer-career-path' +--- + +JavaScript has three static methods for working with String Objects, one of these is **fromCharCode**, which allows you to obtain a string from a sequence of UTF-16 code units. + +## Syntax + +```javascript +String.fromCharCode() +String.fromCharCode(num1) +String.fromCharCode(num1, num2) +String.fromCharCode(num1, num2, /* …, */ numN) +``` + +### Parameters +At least one number between 0 and 65535 (0xFFFF) **representing a UTF-16 code unit**. Numbers greater than 0xFFFF are truncated to the last 16 bits. + +## Example + +```javascript +const nombre = String.fromCharCode(76, 105, 97, 110, 121, 10084, 65039); +console.log(nombre); // "Liany❤️" + +``` + +## Codebyte Example + +```codebyte/js +# Example runnable code block. +const secret = String.fromCharCode( + 76, 111, 110, 103, 32, 108, 105, 118, 101, 32, 116, 104, 101, 32, 107, 105, 116, 116, 105, 101, 115 +); +console.log(secret); // "Long live the kitties" + +``` From 11dc9dc9f4db612c9b7061be4b2bd516a5147082 Mon Sep 17 00:00:00 2001 From: Ariel-GonzAguer Date: Sun, 8 Jun 2025 11:49:06 -0600 Subject: [PATCH 2/4] Fix formatting in fromCharCode documentation syntax section --- .../strings/terms/fromCharCode/fromCharCode.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/content/javascript/concepts/strings/terms/fromCharCode/fromCharCode.md b/content/javascript/concepts/strings/terms/fromCharCode/fromCharCode.md index 79b402dde16..f816b21422b 100644 --- a/content/javascript/concepts/strings/terms/fromCharCode/fromCharCode.md +++ b/content/javascript/concepts/strings/terms/fromCharCode/fromCharCode.md @@ -17,13 +17,14 @@ JavaScript has three static methods for working with String Objects, one of thes ## Syntax ```javascript -String.fromCharCode() -String.fromCharCode(num1) -String.fromCharCode(num1, num2) -String.fromCharCode(num1, num2, /* …, */ numN) +String.fromCharCode(); +String.fromCharCode(num1); +String.fromCharCode(num1, num2); +String.fromCharCode(num1, num2, /* …, */ numN); ``` ### Parameters + At least one number between 0 and 65535 (0xFFFF) **representing a UTF-16 code unit**. Numbers greater than 0xFFFF are truncated to the last 16 bits. ## Example @@ -31,7 +32,6 @@ At least one number between 0 and 65535 (0xFFFF) **representing a UTF-16 code un ```javascript const nombre = String.fromCharCode(76, 105, 97, 110, 121, 10084, 65039); console.log(nombre); // "Liany❤️" - ``` ## Codebyte Example From a96c300a3dc92b240d8fb34b346c0bbcae02b9d5 Mon Sep 17 00:00:00 2001 From: Ariel-GonzAguer Date: Sun, 8 Jun 2025 11:59:49 -0600 Subject: [PATCH 3/4] Fix code block language in fromCharCode documentation --- .../concepts/strings/terms/fromCharCode/fromCharCode.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/javascript/concepts/strings/terms/fromCharCode/fromCharCode.md b/content/javascript/concepts/strings/terms/fromCharCode/fromCharCode.md index f816b21422b..9eded7d5594 100644 --- a/content/javascript/concepts/strings/terms/fromCharCode/fromCharCode.md +++ b/content/javascript/concepts/strings/terms/fromCharCode/fromCharCode.md @@ -36,7 +36,7 @@ console.log(nombre); // "Liany❤️" ## Codebyte Example -```codebyte/js +```codebyte/javascript # Example runnable code block. const secret = String.fromCharCode( 76, 111, 110, 103, 32, 108, 105, 118, 101, 32, 116, 104, 101, 32, 107, 105, 116, 116, 105, 101, 115 From ee67198f99cbada71508f72459d3684204dc3af9 Mon Sep 17 00:00:00 2001 From: Mamta Wardhani Date: Tue, 10 Jun 2025 22:31:57 +0530 Subject: [PATCH 4/4] minor content fixes --- .../terms/fromCharCode/fromCharCode.md | 45 ++++++++++++------- 1 file changed, 28 insertions(+), 17 deletions(-) diff --git a/content/javascript/concepts/strings/terms/fromCharCode/fromCharCode.md b/content/javascript/concepts/strings/terms/fromCharCode/fromCharCode.md index 9eded7d5594..4db46717c6e 100644 --- a/content/javascript/concepts/strings/terms/fromCharCode/fromCharCode.md +++ b/content/javascript/concepts/strings/terms/fromCharCode/fromCharCode.md @@ -1,46 +1,57 @@ --- -Title: 'fromCharCode' -Description: 'Its a static method that returns a string created from the specified sequence of UTF-16 code units.' +Title: 'fromCharCode()' +Description: 'Returns a string created from the specified sequence of UTF-16 code units.' Subjects: + - 'Computer Science' - 'Web Development' Tags: - - 'Strings' - 'Characters' - 'JavaScript' - 'Methods' + - 'Strings' CatalogContent: + - 'introduction-to-javascript' - 'paths/front-end-engineer-career-path' --- -JavaScript has three static methods for working with String Objects, one of these is **fromCharCode**, which allows you to obtain a string from a sequence of UTF-16 code units. +In JavaScript, the **`fromCharCode()`** method creates a string by converting one or more UTF-16 code units (numeric values) into their corresponding characters. This method is often applied in scenarios involving character encoding, dynamic character generation, or simple encryption tasks. It is particularly useful for converting ASCII or Unicode values into readable text. ## Syntax -```javascript -String.fromCharCode(); -String.fromCharCode(num1); -String.fromCharCode(num1, num2); -String.fromCharCode(num1, num2, /* …, */ numN); +```pseudo +String.fromCharCode(num1, num2, ..., numN) ``` -### Parameters +**Parameters:** + +- `num1, num2, ..., numN` (Number): One or more integer values representing UTF-16 code units. Each number should be between 0 and 65535. -At least one number between 0 and 65535 (0xFFFF) **representing a UTF-16 code unit**. Numbers greater than 0xFFFF are truncated to the last 16 bits. +**Return value:** + +Returns a string composed of characters corresponding to the provided UTF-16 code units. ## Example -```javascript -const nombre = String.fromCharCode(76, 105, 97, 110, 121, 10084, 65039); -console.log(nombre); // "Liany❤️" +The following code converts a sequence of UTF-16 code units into the string "Liany❤️" and logs it to the console: + +```js +const number = String.fromCharCode(76, 105, 97, 110, 121, 10084, 65039); +console.log(number); +``` + +The output of this code is: + +```shell +Liany❤️ ``` ## Codebyte Example +Run the following code to understand the working of the `fromCharCode()` method: + ```codebyte/javascript -# Example runnable code block. const secret = String.fromCharCode( 76, 111, 110, 103, 32, 108, 105, 118, 101, 32, 116, 104, 101, 32, 107, 105, 116, 116, 105, 101, 115 ); -console.log(secret); // "Long live the kitties" - +console.log(secret); ```