Lädt...

🔧 Reverse words


Nachrichtenbereich: 🔧 Programmierung
🔗 Quelle: dev.to

Instructions:
Complete the function that accepts a string parameter, and reverses each word in the string. All spaces in the string should be retained.

Examples
"This is an example!" ==> "sihT si na !elpmaxe"
"double spaces" ==> "elbuod secaps"

Thoughts:

  1. I splut the total string into an array of words of type string. 2.Using map function I take every single word(array element) of the array, split the word in individual letters in an array, reverse this array and join it back into a word, reversed this time. const revrs = arr.map((el) => { const rvrEl = el.split("").reverse().join("");
  2. At the end I join all the words in the array together.

Solution:

function reverseWords(str) {
   const arr = str.split(" ");
  const revrs = arr.map((el) => {
    const rvrEl = el.split("").reverse().join("");
    return rvrEl;
  });
  return revrs.join(" ");
}

This is a CodeWars Challenge of 7kyu Rank (https://www.codewars.com/kata/5259b20d6021e9e14c0010d4/train/javascript)

...

🔧 From Words to Numbers: Mastering the Bag of Words Model in NLP


📈 27.63 Punkte
🔧 Programmierung

🔧 Capitalizing Words in PostgreSQL: Handling Hyphenated Words and More


📈 27.63 Punkte
🔧 Programmierung

🎥 Ever stare so long at your document proofreading that words stop looking like words?


📈 27.63 Punkte
🎥 Video | Youtube

🔧 Python Exercise of the Day: Reverse the Order of Words in a Sentence


📈 22.94 Punkte
🔧 Programmierung

🔧 Daily JavaScript Challenge #JS-212: Reverse the Words in a String


📈 22.94 Punkte
🔧 Programmierung

🔧 Daily JavaScript Challenge #JS-180: Reverse Words in a String


📈 22.94 Punkte
🔧 Programmierung

🔧 Reverse words


📈 22.94 Punkte
🔧 Programmierung

🔧 Daily JavaScript Challenge #JS-138: Reverse Words in a String


📈 22.94 Punkte
🔧 Programmierung

🔧 Leetcode - 151. Reverse Words in a String


📈 22.94 Punkte
🔧 Programmierung

🔧 [Algorithm] 151. Reverse Words in a String


📈 22.94 Punkte
🔧 Programmierung

🔧 LeetCode Challenge: 151. Reverse Words in a String - JavaScript Solution 🚀


📈 22.94 Punkte
🔧 Programmierung

🔧 Daily JavaScript Challenge #JS-53: Reverse Words in a Sentence


📈 22.94 Punkte
🔧 Programmierung

🔧 Leetcode - 151. Reverse Words in a String


📈 22.94 Punkte
🔧 Programmierung

🔧 Typescript Coding Chronicles: Reverse Words in a String


📈 22.94 Punkte
🔧 Programmierung

🐧 Apache Reverse Proxy Configuration - A Complete Guide to Apache 2.4.x HTTP/HTTPS Reverse Proxy


📈 18.25 Punkte
🐧 Linux Tipps

🔧 Reverse a string in JavaScript without using reverse()


📈 18.25 Punkte
🔧 Programmierung

🔧 Reverse a string in JavaScript without using reverse()


📈 18.25 Punkte
🔧 Programmierung

🔧 Build a reverse ssh tunnel reverse proxy for (not) fun and (not) profit


📈 18.25 Punkte
🔧 Programmierung

🕵️ Reverse Engineering a DLL Reverse Shell


📈 18.25 Punkte
🕵️ Reverse Engineering

🔧 PostgreSQL Role Inheritance in Reverse: Discovering Descendant Roles in Reverse Gear


📈 18.25 Punkte
🔧 Programmierung

🔧 How to Reverse an Array in JavaScript – JS .reverse() Function


📈 18.25 Punkte
🔧 Programmierung

📰 Reverse-Shell-Generator - Hosted Reverse Shell Generator With A Ton Of Functionality


📈 18.25 Punkte
📰 IT Security Nachrichten

🕵️ Reverse Engineering with Radare2 | TryHackMe Reverse-Elf-ineering Advent of Cyber


📈 18.25 Punkte
🕵️ Reverse Engineering

🕵️ Everythings in reverse, I couldn’t find another reverse subreddit so here is this video


📈 18.25 Punkte
🕵️ Reverse Engineering

📰 HTTP Asynchronous Reverse Shell - Asynchronous Reverse Shell Using The HTTP Protocol


📈 18.25 Punkte
📰 IT Security Nachrichten