字符串的方法,实现将下面这段英文中“mother”替换为“father”,将“her”替换为“his”,并统计下面这段英文有几个单词

"When a mother sits next to her babys cradle and dandles the baby, the Phoenix comes down to the babys pillow, and the glaring feathers of Phoenix make a halo around the babys head.The phoenix flies around rooms of poor people, sprinkles sunshine, and carries the fragrance of violets into the rooms."
参考思路:使用replace方法替换单词,使用split方法分割字符串成数组,数组长度(length属性)即为单词个数

let text = "When a mother sits next to her babys cradle and dandles the baby, the Phoenix comes down to the babys pillow, and the glaring feathers of Phoenix make a halo around the babys head.The phoenix flies around rooms of poor people, sprinkles sunshine, and carries the fragrance of violets into the rooms.";
text = text.replace(/mother/g, "father");
text = text.replace(/her/g, "his");
let word_count = text.split(" ").length;
console.log(text);
console.log("单词数:", word_count);