Challenge 39: Implement the Caesar cipher
Javascript
function caesarCipher(text, shift) { return text.replace(/[a-zA-Z]/g, char => { let baseCharCode = char.toLowerCase() === char ? 'a' .charCodeAt(0) : 'A' .charCodeAt(0); let charCode = char.charCodeAt(0); let shiftedCharCode = ((charCode - baseCharCode + shift) % 26 + 26) % 26 + baseCharCode; return String.fromCharCode(shiftedCharCode); }); } let inputText = "Hello, World!" ; let encryptedText = caesarCipher(inputText, 3); console.log(encryptedText); |
Coding Challenge for Beginners | Coding Practice Challenges
Here’s a simple coding challenge suitable for beginners. This challenge involves writing a function in a programming language of your choice.
Table of Content
- Challenge 1: Print Numbers from 1 to 10
- Challenge 2: Print Odd Numbers Less Than 100
- Challenge 3: Print Multiplication Table with 7
- Challenge 4: Print All Multiplication Tables (1 to 10)
- Challenge 5: Calculate Sum of Numbers from 1 to 10
- Challenge 6: Calculate 10!
- Challenge 7: Sum of Odd Numbers (10 to 30)
- Challenge 8: Celsius to Fahrenheit Conversion
- Challenge 9: Fahrenheit to Celsius Conversion
- Challenge 10: Sum of Numbers in an Array
- Challenge 11: Average of Numbers in an Array
- Challenge 12: Positive Numbers in an Array (Solution 1)
- Challenge 12: Positive Numbers in an Array (Solution 2)
- Challenge 12: Positive Numbers in an Array (Solution 3)
- Challenge 13: Maximum number in an array
- Challenge 14: First 10 Fibonacci numbers without recursion
- Challenge 15: nth Fibonacci number using recursion
- Challenge 16: Check if a number is prime
- Challenge 17: Sum of digits of a positive integer
- Challenge 18: First 100 prime numbers
- Challenge 19: First “nPrimes” prime numbers greater than “startAt”
- Challenge 20: Rotate an array to the left 1 position
- Challenge 21: Rotate an array to the right 1 position
- Challenge 22: Reverse an array
- Challenge 23: Reverse a string
- Challenge 24: Merge two arrays
- Challenge 25: Elements in the first or second array but not both
- Challenge 26: Elements in the first array but not in the second
- Challenge 27: Distinct elements in an array(Solution 1)
- Challenge 27: Distinct elements in an array(Solution 2)
- Challenge 28: Sum of first 100 prime numbers
- Challenge 29: Distance between the first 100 prime numbers
- Challenge 30: Add two positive numbers of indefinite size as strings(Solution 1)
- Challenge 30: Add two positive numbers of indefinite size as strings(Solution 2)
- Challenge 31: Number of words in a text(Solution 1)
- Challenge 31: Number of words in a text(Solution 2)
- Challenge 32: Capitalize the first letter of each word in a text
- Challenge 33: Sum of numbers in a comma-delimited string
- Challenge 34: Words inside a text
- Challenge 35: Convert CSV text to a bi-dimensional array
- Challenge 36: Convert a string to an array of characters
- Challenge 37: Convert a string to an array of ASCII codes
- Challenge 38: Convert an array of ASCII codes to a string
- Challenge 39: Implement the Caesar cipher
- Challenge 40: Bubble sort algorithm
- Challenge 41: Distance between two points defined by their coordinates
- Challenge 42: Check Circle Intersection
- Challenge 43: Extract Column from 2D Array
- Challenge 44: Convert Binary String to Number
- Challenge 45: Sum of Numbers in Jagged Array
- Challenge 46: Find Maximum Number in Jagged Array(Solution 1)
- Challenge 46: Find Maximum Number in Jagged Array(Solution 2)
- Challenge 47: Deep Copy Jagged Array
- Challenge 48: Longest Word(s) in a String
- Challenge 49: Shuffle Array of Strings
- Challenge 50: Generate Unique Random Numbers
- Challenge 51: Frequency of Characters in a String
- Challenge 52: Calculate Fibonacci(500)
- Challenge 53: Calculate 70! with High Precision