Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,13 @@ <h2>Broadcasting and vectorized operations</h2>
<p>
<input type="button" class="btn btn-primary" value="arange" onclick="broadcast()" />
<input type="button" class="btn btn-primary" value="+" onclick="operation(this.value)" />
<input type="button" class="btn btn-primary" value="+=" onclick="operation(this.value)" />
<input type="button" class="btn btn-primary" value="-" onclick="operation(this.value)" />
<input type="button" class="btn btn-primary" value="-=" onclick="operation(this.value)" />
<input type="button" class="btn btn-primary" value="*" onclick="operation(this.value)" />
<input type="button" class="btn btn-primary" value="*=" onclick="operation(this.value)" />
<input type="button" class="btn btn-primary" value="/" onclick="operation(this.value)" />
<input type="button" class="btn btn-primary" value="/=" onclick="operation(this.value)" />
</p>

<p>
Expand Down
4 changes: 1 addition & 3 deletions script.js
Original file line number Diff line number Diff line change
Expand Up @@ -252,8 +252,6 @@ const broadcast = () => {
return alert("Please enter a variable name in the 'variable' field, in the 'Basic NumPy arrays' section.");
} else if (broadcastNumber.value === "") {
return alert("Please enter a number in the 'value' field, in the 'Broadcasting and vectorised operations' section.");
} else if (!(Math.abs(Number(broadcastNumber.value)) >= 0) || broadcastNumber.value === "") {
return alert("Please enter a number in the 'value' field, in the 'Broadcasting and vectorised operations' section.");
} else {
document.editor.textbox.value+="\n" + variable.value + " = np.arange(" + broadcastNumber.value + ")";
}
Expand All @@ -263,7 +261,7 @@ const operation = (arg) => {
if (variable.value === "") {
return alert("Please enter a variable name in the 'variable' field, in the 'Basic NumPy arrays' section.");
} else if (broadcastNumber.value === "") {
return alert("Please enter a number in the 'value' field, , in the 'Broadcasting and vectorised operations' section.");
return alert("Please enter a number in the 'value' field, in the 'Broadcasting and vectorised operations' section.");
} else {
document.editor.textbox.value+="\n" + variable.value + " " + arg + " " + broadcastNumber.value;
}
Expand Down