Skip to content

Commit afa0953

Browse files
author
Eric Koleda
authored
Merge pull request googleworkspace#107 from matheusbn/master
Simplify condition
2 parents db3ad68 + f4ec6de commit afa0953

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

docs/translate/translate.gs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ function showSidebar() {
7373
*/
7474
function getSelectedText() {
7575
var selection = DocumentApp.getActiveDocument().getSelection();
76+
var text = [];
7677
if (selection) {
77-
var text = [];
7878
var elements = selection.getSelectedElements();
7979
for (var i = 0; i < elements.length; ++i) {
8080
if (elements[i].isPartial()) {
@@ -97,13 +97,9 @@ function getSelectedText() {
9797
}
9898
}
9999
}
100-
if (!text.length) {
101-
throw new Error('Please select some text.');
102-
}
103-
return text;
104-
} else {
105-
throw new Error('Please select some text.');
106100
}
101+
if (!text.length) throw new Error('Please select some text.');
102+
return text;
107103
}
108104

109105
/**

0 commit comments

Comments
 (0)