You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
console.log('Task2 ',reverseEachWord('You don\'t have to do anything special to begin using the DOM. Different browsers have different implementations of the DOM'));
45
+
console.log('Task2 ',reverseEachWord('The Document Object Model (DOM) is a programming interface for HTML and XML documents'));
46
+
47
+
48
+
49
+
//Task3
50
+
51
+
functionreverseEachWord2(str,boolean){
52
+
letarrStr=str.split(' ');
53
+
letnewArrStr=[];
54
+
arrStr.forEach(function(elem,index,arr){
55
+
letarrElem=elem.split('');
56
+
letreversElemInArr=arrElem.reverse();
57
+
letreversElemInString=reversElemInArr.join('');
58
+
newArrStr.push(reversElemInString);
59
+
});
60
+
if(boolean===true){
61
+
newArrStr.reverse();
62
+
};
63
+
returnnewArrStr.join(' ');
64
+
};
65
+
66
+
console.log('Task3 ',reverseEachWord2('The Document Object Model (DOM) is a programming interface for HTML and XML documents',true));
67
+
console.log('Task3 ',reverseEachWord2('Hi my Name is',false));
68
+
console.log('Task3 ',reverseEachWord2('Hi my Name is',true));
0 commit comments