https://leetcode.com/problems/reverse-prefix-of-word/


Runtime: 71 ms, faster than 84.38% of TypeScript online submissions for Reverse Prefix of Word.

Memory Usage: 45.1 MB, less than 6.25% of TypeScript online submissions for Reverse Prefix of Word.


```typescript
function reversePrefix(word: string, ch: string): string {
    //8:03
    if (!(word.split("").includes(ch))) {
        return word
    }
    
    let firstPart = []
    let secondPart = []
    let swich = false
    
    for (const char of word) {
        if (swich == false) {
            firstPart.push(char)
        }
        if (swich == true) {
            secondPart.push(char)
        }
        if (char == ch) {
            swich = true
        }
    }
    
    firstPart.reverse()
    
    return firstPart.join("") + secondPart.join("")
    //8:08
};
```

